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

conn pool consistency fix #61

Merged
merged 1 commit into from
Dec 21, 2022
Merged

Conversation

pjain1
Copy link
Contributor

@pjain1 pjain1 commented Dec 21, 2022

Fixes a consistency bug where changes made in one DuckDB connection are not immediately reflected in other DuckDB connections. Looks like the problem is that In the go-duckdb driver, the Open function creates a new DB handle (using duckdb_open) and new connection handle (using duckdb_connect) each time. So the use of multiple DB handles seems to be the problem here. Thanks @begelundmuller for the analysis.

Driver now implements DriverContext so sql.DB will call OpenConnector to obtain a Connector and then invoke
that Connector's Connect method to obtain each needed connection instead of invoking Driver's Open method which was creating new C.duckdb_database each time. Now we create database object once on call to OpenConnector and call C.duckdb_connect on same database to obtain new connections on call to Connect.

@marcboeker
Copy link
Owner

LGTM and thanks for the PR. I've never had this use case so far but I'm glad you have it, so connection pooling is now possible 🙂

@pjain1
Copy link
Contributor Author

pjain1 commented Dec 21, 2022

Thanks for the quick review and merge.

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.

None yet

2 participants