Skip to content
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

driver: context support #997

Merged
merged 8 commits into from
Feb 24, 2025
Merged

driver: context support #997

merged 8 commits into from
Feb 24, 2025

Conversation

serprex
Copy link
Contributor

@serprex serprex commented Feb 21, 2025

database/sql QueryContext falls back to checking if context is done before calling Query, so query does not get cancelled when context is cancelled once execution starts

driver.Queryer is deprecated

Unfortunately supporting this on top of net.Conn requires a goroutine. But that goroutine can be shared across lifetime of connection since connection doesn't need to be threadsafe

To cancel ongoing Read/Write the connection is closed when context finishes

At the end of the function active context is switched to context.Background(). Some error handling could be implemented around receiving non-background context when active context is a non-background context, as that implies thread safety has been violated

Close instead of SetTimeout hack
implement more interfaces, with assertions
@serprex serprex changed the title [POC] context support driver: context support Feb 21, 2025
@serprex serprex marked this pull request as ready for review February 22, 2025 02:27
Copy link
Collaborator

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lance6716 lance6716 merged commit 5fc8c87 into go-mysql-org:master Feb 24, 2025
15 checks passed
serprex added a commit to PeerDB-io/peerdb that referenced this pull request Feb 25, 2025
based on go-mysql-org/go-mysql#997 without having to switch to `database/sql`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants