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
We received an error ERROR: cache lookup failed for type 16488 (SQLSTATE XX000) upon making a db query. The root cause of the error is because the service had a stale connection to a database and service owners had run a migration on the DB.
In the old pod, it was still making queries with that stale connection, there was a type consistency issue where the connection didn’t know of the new type created by the migration. But in the new pod, everything was fine. The issue gets resolved once the service owner restarted the pods and the connections got reset.
Question
Now *sql.driverConn.validateConnection() marks a connection "needReset" (after calling *driverConn.releaseConn()) and *sql.driverConn.putConn() puts the connection to the current connection pool. The connection is reset when it's picked from the pool with “needReset” marker. My understanding is that we can't get a reset connection until all connections in the pool are marked "needReset".
My question is how can we reset the connection manually when we feel it's necessary? Or any advice for this case? Thank you!
The text was updated successfully, but these errors were encountered:
Thanks, this makes sense! It would be even nicer if, upon cache lookup failure, we reset the connection and try again. Perhaps this needs to be done at application layer, but would be very convenient for a lot of cases if it could be done in the library.
seankhliao
changed the title
go/src/database/sql: need to reset connections based on error
database/sql: need to reset connections based on error
Jan 24, 2025
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
Background
We received an error
ERROR: cache lookup failed for type 16488 (SQLSTATE XX000)
upon making a db query. The root cause of the error is because the service had a stale connection to a database and service owners had run a migration on the DB.In the old pod, it was still making queries with that stale connection, there was a type consistency issue where the connection didn’t know of the new type created by the migration. But in the new pod, everything was fine. The issue gets resolved once the service owner restarted the pods and the connections got reset.
Question
Now
*sql.driverConn.validateConnection()
marks a connection "needReset" (after calling*driverConn.releaseConn()
) and*sql.driverConn.putConn()
puts the connection to the current connection pool. The connection is reset when it's picked from the pool with “needReset” marker. My understanding is that we can't get a reset connection until all connections in the pool are marked "needReset".My question is how can we reset the connection manually when we feel it's necessary? Or any advice for this case? Thank you!
The text was updated successfully, but these errors were encountered: