-
Hello! I was wondering if anyone can help me understand a strange behavior when using I've seen in this CHANGELOG that now we can Allow background pool connections to continue even if cause is canceled (James Hartig), but I haven't managed to get that working. Browsing the code, I came across this piece of code that is closing the connection if any error occurs. In other functions, net timeout errors are explicitly ignored, as it can be seen here, and also here. Should this types of error also be ignored in the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
There's multiple issues you reference One is the pool establishing a connection not getting interrupted when the query that triggered the connection is interrupted. AFAIK this is working properly. So if that is not happening there is a bug somewhere. But you didn't say if you are using database/sql or pgxpool. This change only affects pgxpool. I don't know if database/sql is affected or not. The second issue is closing the connection on (almost) any error. The reason for this is it is extremely difficult to reliably recover from an interrupted connection. There are so many different edge cases that it is better to reestablish a new connection. The places that allow timeouts are to support interrupting |
Beta Was this translation helpful? Give feedback.
-
@jackc Sorry if I missed some points. I am using |
Beta Was this translation helpful? Give feedback.
@jackc Sorry if I missed some points. I am using
pgxpool
and the behavior I am getting is the following: I make a query that is canceled by its context. When it happens, the connection is automatically closed even though it wasn't an actual problem with the connection. This is making my application create a bunch of connections when this timeout happens. From what I understood from thev4.17
changelog I should be able to reuse that connection. Right?