fix: chembl_bridge()/dti_pairs() conflict under concurrent calls - #2
Merged
Merged
Conversation
Regression from 0.2.2's connection reuse (connect() now returns a cursor on a shared base connection per release instead of a fresh duckdb.connect()): chembl_bridge() and dti_pairs() each register their result as a named CREATE OR REPLACE VIEW, catalog-mutating DDL that's now shared, mutable state on that connection. Two calls racing that DDL from different threads collide. Reproduced directly: a 24-thread stress run mixing chembl_bridge() and dti_pairs() calls failed 46/48 of the time with DuckDB's "Catalog write-write conflict on create". Fixed by referencing the parquet file inline via read_parquet() in the query itself instead of registering a named view first: no catalog write, nothing to conflict on. Verified with the same stress run (0/48 errors) and a broader 64-call mix of every function in the package running concurrently from a cold start (0 errors). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L4ztUhMgoMFRicB8uiYx76
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chembl_bridge()anddti_pairs()each registered their result as a namedCREATE OR REPLACE VIEW, which is catalog-mutating DDL. Now thatconnect()returns a cursor on a shared base connection per release, that DDL is shared mutable state, and two calls racing it from different threads conflict. Reproduced directly: a 24-thread stress run mixing both functions failed 46/48 calls with DuckDB'sCatalog write-write conflict on create.read_parquet()directly in the query instead of registering a named view first, so there's no catalog write to race on.Test plan
pytest -q— 40 passedmypy src/scigantic_bindingdb(strict) — clean🤖 Generated with Claude Code
https://claude.ai/code/session_01L4ztUhMgoMFRicB8uiYx76