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

Synchronise extensions before reconnect #316

Merged
merged 7 commits into from
Oct 21, 2024
Merged

Synchronise extensions before reconnect #316

merged 7 commits into from
Oct 21, 2024

Conversation

Y--
Copy link
Collaborator

@Y-- Y-- commented Oct 18, 2024

If duckdb.extensions table is inserted, updated or deleted in same connection we would not sync changes for next query. Introduce sequence that keeps track of each change so we can compare with and sync if required.

Inspired from #253

Fixes #278

@Y-- Y-- requested review from JelteF and mkaruza October 18, 2024 14:36
@Y-- Y-- enabled auto-merge (squash) October 18, 2024 15:25
test/regression/expected/extensions.out Outdated Show resolved Hide resolved
test/regression/expected/extensions.out Outdated Show resolved Hide resolved
src/pgduckdb_duckdb.cpp Outdated Show resolved Hide resolved
@JelteF JelteF added the bug Something isn't working label Oct 20, 2024
src/pgduckdb_duckdb.cpp Outdated Show resolved Hide resolved
src/pgduckdb_duckdb.cpp Outdated Show resolved Hide resolved
@@ -202,6 +198,8 @@ DuckDBManager::LoadExtensions(duckdb::ClientContext &context) {
if (extension.name == "httpfs") {
continue;
}

DuckDBQueryOrThrow(context, "INSTALL " + extension.name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, was this not needed before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test we insert rows directly in extensions table, so we don't run the install_extension function. I hesitated using the function or making sure that no matter what we install the extension if needed as it makes the UX nicer, though I don't have strong opinion on it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is INSTALL an actual no-op if the extension is already installed? Or does it do something semi-expensive like network requests, which would be good to avoid on every DB initialization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it is a no-op, cf. here

auto drop_secret_cmd = duckdb::StringUtil::Format("DROP SECRET pgduckb_secret_%d;", secret_id);
pgduckdb::DuckDBQueryOrThrow(drop_secret_cmd);
pgduckdb::DuckDBQueryOrThrow(context, drop_secret_cmd);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change make sure that we don't have a re-entrant call to DuckDBManager::Get

@Y-- Y-- merged commit 25ce44d into main Oct 21, 2024
4 checks passed
@Y-- Y-- deleted the yl/reload-extensions branch October 21, 2024 09:16
@JelteF JelteF mentioned this pull request Oct 23, 2024
JelteF added a commit that referenced this pull request Oct 23, 2024
Fixes #217 

This changes the defaults for `duckdb.max_memory` and
`duckdb.disabled_filesystems` to the agreed upon settings. While doing
that I found two issues that this also fixes:
1. `duckdb.disabled_filesystems = 'LocalFilesystem'` was basically a way
to make DuckDB execution unusable, due to us doing file system access
when initializing the database/connection. So now we enable the setting
later. Also we now don't call `INSTALL {extension}` during connection
initialization anymore.
2. #316 didn't fix the loading of extensions when
`duckdb.install_extension()` was called. Only for direct inserts to the
`duckdb.extensions` table. That's fixed by not using the low-level
`CatalogTupleInsert`, and instead switching to SPI.
3. Postgres superusers should not be restricted by
`duckdb.disabled_filesystems`, they should be able to do whatever they
want. So now this setting is not actually configured for superusers
anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extensions are not synced before reconnect
2 participants