Skip to content

database/sql: use errors.Is when checking for driver.ErrBadConn #47142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kardianos opened this issue Jul 12, 2021 · 5 comments
Closed

database/sql: use errors.Is when checking for driver.ErrBadConn #47142

kardianos opened this issue Jul 12, 2021 · 5 comments

Comments

@kardianos
Copy link
Contributor

As of Go1.17, retry logic and various other logic rely on the exact error value driver.ErrBadConn being returned if the connection is in a bad state. Various calls, such as the IsValid method may be called if supported on a driver that will prevent bad connections from poisoning the pool. However, right now, a driver still has to make a decision to return an interesting error or to get retry logic.

See denisenkom/go-mssqldb#586

I propose that throughout database/sql we use errors.Is rather then a direct comparison to driver.ErrBadConn.

@gopherbot gopherbot added this to the Proposal milestone Jul 12, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/333949 mentions this issue: database/sql: use errors.Is when checking errors for driver.ErrBadConn

@kardianos
Copy link
Contributor Author

@rsc What would be the process for this to move forward?

@rsc
Copy link
Contributor

rsc commented Oct 6, 2021

This seems OK as long as we document it for driver authors. Adding to minutes.

@rsc
Copy link
Contributor

rsc commented Oct 13, 2021

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented Oct 20, 2021

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: database/sql: use errors.Is when checking for driver.ErrBadConn database/sql: use errors.Is when checking for driver.ErrBadConn Oct 20, 2021
@rsc rsc modified the milestones: Proposal, Backlog Oct 20, 2021
@rsc rsc moved this to Accepted in Proposals Aug 10, 2022
@rsc rsc added this to Proposals Aug 10, 2022
@golang golang locked and limited conversation to collaborators Nov 3, 2022
@rsc rsc removed this from Proposals Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants