Skip to content

fix(iceberg): apply connect-time search_path control-plane-side, after metadata init#610

Merged
fuziontech merged 1 commit into
mainfrom
iceberg-connect-search-path-fix
May 22, 2026
Merged

fix(iceberg): apply connect-time search_path control-plane-side, after metadata init#610
fuziontech merged 1 commit into
mainfrom
iceberg-connect-search-path-fix

Conversation

@fuziontech
Copy link
Copy Markdown
Member

Summary

Follow-up fix to #606. The connect-time search_path (startup options=-c search_path=iceberg.public / PGOPTIONS / JDBC currentSchema) 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:

  1. Clobbered. The control plane runs InitSessionDatabaseMetadata after session create, and its defer ends with SET search_path = 'main,memory.main' — overwriting whatever the worker set. (That's why options=search_path=ducklake.main "worked" — it just matched the default.)
  2. Breaks init. When the worker-set default pointed at the iceberg REST catalog, InitSessionDatabaseMetadata itself failed → the whole connection errored with FATAL: failed to initialize session database metadata.

Verified live on prod (with #606 deployed): options=search_path=iceberg.public errored; ducklake.main was silently reset to the default.

Fix

  • Revert feat(iceberg): honor connect-time search_path to pick default catalog #606's worker-side threading: drop WorkerCreateSessionPayload.SearchPath and the searchPath params on SessionPool.CreateSession, SessionManager.CreateSession/CreateSessionWithProtocol, createSessionOnWorker, ManagedWorker.CreateSession, and initSearchPath.
  • Apply CP-side: in control.go, right after InitSessionDatabaseMetadata + HasAttachedCatalog succeed (i.e. after the clobbering defer, and after metadata init has run against the safe ducklake default), run SET 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 by control.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

…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>
@fuziontech fuziontech merged commit 533a1c9 into main May 22, 2026
22 checks passed
@fuziontech fuziontech deleted the iceberg-connect-search-path-fix branch May 22, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant