Skip to content

Add startup postgresConfig and WAL-compatible pgoutput support#897

Open
sorenbs wants to merge 1 commit intoelectric-sql:mainfrom
prisma:codex/wal-config
Open

Add startup postgresConfig and WAL-compatible pgoutput support#897
sorenbs wants to merge 1 commit intoelectric-sql:mainfrom
prisma:codex/wal-config

Conversation

@sorenbs
Copy link

@sorenbs sorenbs commented Feb 24, 2026

Summary

This PR enables reliable logical WAL support for @electric-sql/pglite consumers (specifically ppg-dev) by adding startup-time Postgres config support and wiring pgoutput-compatible symbol exports.

ppg-dev depends on setting postmaster-level GUCs at startup (wal_level=logical, replication slot/sender limits), and on loading pgoutput for logical decoding. This PR makes that work end-to-end.

Changes

  1. Add startup Postgres config API in pglite:
  • PGliteOptions.postgresConfig?: Record<string, string | number | boolean>
  • Config is serialized and passed to backend startup as PGLITE_POSTGRES_CONFIG.
  1. Apply startup config inside wasm backend (postgres-pglite submodule):
  • Parse PGLITE_POSTGRES_CONFIG.
  • Call SetConfigOption(..., PGC_POSTMASTER, PGC_S_ARGV) before normal startup proceeds in both startup paths.
  1. Export pgoutput-required core symbols/globals:
  • Add pgoutput-required imports to included.pglite.imports so the main wasm exports what pgoutput.so needs at load time.
  1. Add shutdown guard:
  • Handle numeric Infinity sentinel on close (emscripten shutdown anomaly path) so close remains successful.
  1. Add test coverage:
  • New packages/pglite/tests/postgres-config.test.ts verifies startup application of:
    • wal_level=logical
    • max_replication_slots
    • max_wal_senders

Validation

  • pglite tests:
    • vitest tests/postgres-config.test.ts tests/basic.test.ts --run pass.
  • WAL smoke:
    • pg_create_logical_replication_slot(..., 'pgoutput') succeeds.
    • pg_logical_slot_get_binary_changes(...) returns changes.
  • ppg-dev:
    • WAL integration tests pass in dev/server/src/db.wal.test.ts.

Dependency

This PR depends on the corresponding prisma/postgres-pglite branch/PR that contains the wasm/backend symbol-export and startup-config plumbing. electric-sql/postgres-pglite#64

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