fix: share duckdb adapter is overlapping data files#2039
Merged
Conversation
tobymao
reviewed
Jan 29, 2024
tobymao
approved these changes
Jan 29, 2024
8320190 to
9400be8
Compare
9400be8 to
ef9e236
Compare
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.
Part of fix for: #2037
Result of this change: #1975
Prior to this change we would allow multiple adapters to share a common data file for DuckDB. This actually works fine until multiple adapters are created again pointed to the already created file and then the second adapter (typically state sync) will not read any data. This is why testing before of having multiple adapter run a plan and check the result did not show any issues.
The solution is to check when creating a new adapter for DuckDB if the new adapter is going to point to file that overlaps a file already used by another adapter. If so, we just reuse the past adapter. This has a downside that any additional configuration associated with the new adapter is ignored. One could consider merging the previous and new catalogs together if this overlap is detected but then it doesn't address other config. For example, what if the new one has other connection config set? How do we merge those? I'm wondering if this naive approach will work in most cases to where we can handle the more complex situations later. For example we will eventually want to support Motherduck and that could be a good time to rework things with a more robust use-case in mind.