Skip to content

Fix file persistence session initialization#678

Open
sueun-dev wants to merge 1 commit into
PostHog:mainfrom
sueun-dev:fix-file-persistence-session-init
Open

Fix file persistence session initialization#678
sueun-dev wants to merge 1 commit into
PostHog:mainfrom
sueun-dev:fix-file-persistence-session-init

Conversation

@sueun-dev
Copy link
Copy Markdown

This fixes standalone file-backed connections failing during session metadata initialization when the memory catalog is not attached yet.

What changed:

  • Attach an in-memory memory catalog on the missing-memory-catalog path before installing session metadata views.
  • Restore standalone file-persistence sessions to the persisted physical catalog/search path after metadata setup.
  • Add regression coverage for metadata initialization and a PG-wire reconnect path with file_persistence enabled.

Why:
Issue #561 reports file_persistence: true failing during connection startup with No catalog + schema named "memory" found. The metadata setup needs the compatibility views in memory, but standalone file-backed connections can start without that catalog attached.

Checked:

  • go test -run TestInitSessionDatabaseMetadataWorksOnFileBackedDatabase ./server/sessionmeta
  • go test -run TestFilePersistenceStandaloneConnectionInitializesSession ./server
  • go test ./server/sessionmeta ./server
  • just build
  • just lint
  • just test-unit
  • Not run: Docker-backed integration tests because Docker is not installed in this local environment.

Fixes #561

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread server/conn.go
Comment on lines +1094 to +1095
if c.server.cfg.FilePersistence && !duckLakeAttached && !icebergAttached {
if _, err := c.executor.ExecContext(initCtx, "USE "+sqlcore.QuoteIdentifier(c.username)); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

file_persistence: true breaks standalone mode — "No catalog + schema named memory found"

1 participant