Make DuckDB attachments logic more robust #508
Closed
+61
−50
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.
Note: draft is I found out that DuckDB does not recognize created tables after file was attached so this should be done when all accelerated tables are available.
Fixes DuckDB errors caused by a race condition when multiple connections attempt to attach databases concurrently.
When multiple connections called
query_arrow()simultaneously, each would:PRAGMA database_listATTACH IF NOT EXISTS '{db}' AS attachment_{random_id}_{i}one by oneRace condition: Between step 1 (check) and steps 3 (attach one by one), another connection could attach the same file or retrieve only partially attached databases. This result into errors
All DuckDB connections acquired from a single pool or created via
try_clone()share the same catalog including attached databases, but not thesearch_pathwhich is connection-level setting. PR updates attachment logic to attach databases once during pool initialization and use pre-computed search path for individual connections setup (`SET search_path = '...'] is a fast, idempotent session-level command)