fix(iceberg): apply connect-time search_path control-plane-side, after metadata init#610
Merged
Merged
Conversation
…r metadata init #606 threaded the client's connect-time search_path (startup `options`) all the way to the worker's initSearchPath. That can't work for the pgwire path: 1. InitSessionDatabaseMetadata (run by the CP after session create) ends its defer with `SET search_path = 'main,memory.main'`, clobbering whatever the worker set — so even ducklake.public never stuck. 2. When the worker-set default pointed at the iceberg REST catalog, the metadata-init step itself failed ("failed to initialize session database metadata"), so `options=-c search_path=iceberg.public` errored the whole connection. Verified live on prod: with #606 deployed, `options=search_path=iceberg.public` either errored or returned the default. Fix: revert the worker-side threading (WorkerCreateSessionPayload.SearchPath, the searchPath params on SessionPool/SessionManager/ManagedWorker CreateSession and initSearchPath) and apply the sanitized client search_path in the control plane right AFTER InitSessionDatabaseMetadata + HasAttachedCatalog succeed — i.e. after the clobbering defer and after metadata init has run against the safe ducklake default. memory.main is appended; failures log and fall back. server/startup_options.go (ParseStartupOptions/SanitizeSearchPath) is unchanged and still used by control.go. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Follow-up fix to #606. The connect-time
search_path(startupoptions=-c search_path=iceberg.public/ PGOPTIONS / JDBCcurrentSchema) didn't actually work for pgwire as #606 implemented it.#606 threaded the value to the worker's
initSearchPath(at session create). Two problems make that impossible:InitSessionDatabaseMetadataafter session create, and itsdeferends withSET search_path = 'main,memory.main'— overwriting whatever the worker set. (That's whyoptions=search_path=ducklake.main"worked" — it just matched the default.)InitSessionDatabaseMetadataitself failed → the whole connection errored withFATAL: failed to initialize session database metadata.Verified live on prod (with #606 deployed):
options=search_path=iceberg.publicerrored;ducklake.mainwas silently reset to the default.Fix
WorkerCreateSessionPayload.SearchPathand thesearchPathparams onSessionPool.CreateSession,SessionManager.CreateSession/CreateSessionWithProtocol,createSessionOnWorker,ManagedWorker.CreateSession, andinitSearchPath.control.go, right afterInitSessionDatabaseMetadata+HasAttachedCatalogsucceed (i.e. after the clobbering defer, and after metadata init has run against the safe ducklake default), runSET search_path = '<client>,memory.main'on the executor. Failures log and fall back to the default.server/startup_options.go(ParseStartupOptions/SanitizeSearchPath, with the injection-safety tests) is unchanged and still used bycontrol.go.Result
USE iceberg(#607) already works in prod. After this lands + promotes, the connection-string one-liner works too:psql "host=<org>.dw.us.postwh.com user=… dbname=… sslmode=require options=-c search_path=iceberg.public"Build + vet + unit tests green locally.
🤖 Generated with Claude Code