Fix file persistence session initialization#678
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8a20ccfbe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if c.server.cfg.FilePersistence && !duckLakeAttached && !icebergAttached { | ||
| if _, err := c.executor.ExecContext(initCtx, "USE "+sqlcore.QuoteIdentifier(c.username)); err != nil { |
There was a problem hiding this comment.
Guard file catalog selection on DataDir
When FilePersistence is true but DataDir is empty, DuckDBDSN/openBaseDB intentionally fall back to :memory: (covered by the existing empty-DataDir fallback test), so there is no catalog named after c.username. This new branch still runs USE <username> for that configuration and will turn every standalone connection into a FATAL failed to select file-backed catalog; gate this on an actual file-backed database, e.g. cfg.DataDir != "", so the in-memory fallback continues to work.
Useful? React with 👍 / 👎.
This fixes standalone file-backed connections failing during session metadata initialization when the
memorycatalog is not attached yet.What changed:
memorycatalog on the missing-memory-catalog path before installing session metadata views.file_persistenceenabled.Why:
Issue #561 reports
file_persistence: truefailing during connection startup withNo catalog + schema named "memory" found. The metadata setup needs the compatibility views inmemory, but standalone file-backed connections can start without that catalog attached.Checked:
go test -run TestInitSessionDatabaseMetadataWorksOnFileBackedDatabase ./server/sessionmetago test -run TestFilePersistenceStandaloneConnectionInitializesSession ./servergo test ./server/sessionmeta ./serverjust buildjust lintjust test-unitFixes #561