You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, pgx uses net.SetTimeout to implement context cancellation and it attempts to recover from the network timeouts when possible.
There are three different distinct cases that are or were handled:
A timeout occurs during a Write resulting in a partial write. We always consider this a fatal error and close the connection in this case as there is no way to reliably recover.
A timeout occurs during a Read. Because of the underlying message buffering it should always be safe to recover from these errors. pgx does attempt to recover from these.
Trying to recover from timeouts is a very complex and error prone part of the code. (#494, #506, ....)
I propose abandoning the effort and considering all errors on Read or Write fatal. This should have no effect on anyone using the connection pool aside from removing a source of heisenbugs. The only impacted use case I can see is using a single connection with context cancellations and needing to recover and continuing to use that connection after a cancellation. That seems to be very unusual case -- and it never could be done entirely reliably since some timeouts always were fatal.
The text was updated successfully, but these errors were encountered:
Currently, pgx uses
net.SetTimeout
to implement context cancellation and it attempts to recover from the network timeouts when possible.There are three different distinct cases that are or were handled:
Write
resulting in a partial write. We always consider this a fatal error and close the connection in this case as there is no way to reliably recover.Write
resulting in 0 bytes written. Previously, we attempted to recover from this case. However, this case still breaks a TLS connection (and worse it is not reported properly: crypto/tls: permanently broken tls.Conn should not return temporary net.Error golang/go#29971) So we now always consider this a fatal error as well.Read
. Because of the underlying message buffering it should always be safe to recover from these errors. pgx does attempt to recover from these.Trying to recover from timeouts is a very complex and error prone part of the code. (#494, #506, ....)
I propose abandoning the effort and considering all errors on
Read
orWrite
fatal. This should have no effect on anyone using the connection pool aside from removing a source of heisenbugs. The only impacted use case I can see is using a single connection with context cancellations and needing to recover and continuing to use that connection after a cancellation. That seems to be very unusual case -- and it never could be done entirely reliably since some timeouts always were fatal.The text was updated successfully, but these errors were encountered: