Skip to content

Prototype: native runtime for local Postgres (bundled PostgreSQL + pg_clickhouse) - #1465

Draft
sdairs wants to merge 5 commits into
mainfrom
claude/pg-native-runtime
Draft

sdairs wants to merge 5 commits into
mainfrom
claude/pg-native-runtime

Conversation

@sdairs

@sdairs sdairs commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Why: local postgres needs Docker and has no pg_clickhouse. Prototype for #1464: run PostgreSQL natively so local ClickHouse + Postgres + pg_clickhouse works without containers.

What:

  • local postgres start downloads a sha256-verified bundle from the sdairs/pg-bundles manifest, caches it in ~/.clickhouse/postgres/, runs initdb and a loopback-only postmaster.
  • --docker keeps the container runtime; existing Docker instances resume unchanged.
  • local install postgres@18 installs the bundle (--docker pulls the image).
  • As root, the server runs as postgres or nobody; Linux uses System V shared memory.

QA: fmt, both clippy configurations, cargo test -p clickhousectl, script tests; end to end on macOS arm64, Linux arm64, and as root in an ubuntu:24.04 container.

Risks: root with HOME=/root fails by design (postgres_directory_not_searchable) pending a decision on a root-only location.

Refs #1464

🤖 Generated with Claude Code

sdairs and others added 5 commits November 16, 2026 16:53
)

Prototype. `local postgres start` now runs a postmaster from a portable
PostgreSQL + pg_clickhouse bundle instead of a Docker container; `--docker`
keeps the container runtime, and an instance keeps the runtime it was
created with.

- pg_bundle: manifest fetch (no credentials), mandatory sha256 check before
  extraction, cache in ~/.clickhouse/postgres keyed on name + sha256 prefix,
  atomic install, cache-first resolution so resumes work offline.
- pg_native: initdb via --pwfile with scram-sha-256 and the builtin C.UTF-8
  locale, loopback-only postmaster in its own process group, pg_isready
  readiness, SIGINT then SIGQUIT stop guarded by postmaster.pid and cwd,
  0600 state file with credentials and the bundle identity last used.
- postgres: one runtime decision for start (select_start_runtime) and
  ServerInfo::pg_runtime for everything else; Docker-only options and root
  are usage errors.
- `local install postgres@<version>` installs the bundle; `--docker` pulls
  the image.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… to --docker (#1464)

local_postgres_native_test drives install, checksum and manifest failures,
start/stop/resume/remove and rollback against a file:// bundle source whose
programs are shell scripts, with no network or real PostgreSQL. Tests and
the integration battery that exercise the Docker runtime now ask for it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…er (#1464)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…sysv shared memory on Linux (#1464)

- As root, initdb and the postmaster drop to `postgres`, else `nobody`
  (chdir /, setgroups, setgid, setuid before exec); no user is created and
  the instance directory is chowned to that user. Credentials stay root-only.
- The server user must be able to enter every directory on the way to the
  bundle cache and the instance; otherwise the start fails first with
  postgres_directory_not_searchable, naming the directory. Nothing is chmodded.
- An existing instance runs as the owner of its data directory, so root can
  start a user's instance; rewritten metadata keeps its owner.
- Liveness also accepts a postmaster started on the data directory (-D), for
  root in a container that cannot read another user's cwd.
- Linux: dynamic_shared_memory_type=sysv for initdb and the server, so a
  small /dev/shm does not fail bootstrap or parallel queries. macOS keeps posix.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ry setting (#1464)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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