Make extension callback registration thread-safe, and change extension callback registration APIs to enable this#20599
Merged
Mytherin merged 12 commits intoduckdb:v1.5-variegatafrom Jan 20, 2026
Conversation
… iteration of extension callbacks, and move OperatorExtension over
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.
Follow-up from #20547
There are various extension callbacks that extensions can register, e.g.:
ParserExtensionStorageExtensionOperatorExtensionOptimizerExtensionExtensionCallbackCurrently registering these extensions is not done in a thread-safe manner. As a result, loading extensions that register these callbacks while concurrent activity is taking place in the database is not safe. This usually doesn't matter as extensions are generally loaded up-front, but long-term it would be better to just use thread-safe interfaces here.
We use the same trick as we did in #20547 for making these registrations thread-safe while limiting the impact on reading as much as possible - i.e. the cost of making this thread safe is almost entirely pushed onto the registration (which is generally rarely done - i.e. we only register a few extensions in total).
As a consequence of this, the API for registering these extensions is now different, e.g. instead of doing this:
config.storage_extensions["ducklake"] = make_uniq<DuckLakeStorageExtension>();We now need to do this:
The same applies for the other types:
Transient Includes Removal
Now that these extensions are no longer part of the DBConfig, their includes have also been removed from
config.hpp. This uncovered the fact that we were transiently including a lot of stuff in the DBConfig through these extensions. Since the DBConfig is also included in a lot of places, this meant we were including a lot of files in a lot of places.I've opted to remove these includes to limit include propagation - but this does mean that a lot of files that previously depended on these transient includes now need to actually include what they are using. Common culprits based on fixing this seem to be:
duckdb/planner/expression/bound_columnref_expression.hppduckdb/parser/expression/columnref_expression.hppduckdb/planner/binder.hppduckdb/catalog/catalog_search_path.hpp