Skip to content

fix: run postgresql container with init so orphaned healthcheck processes don't crash postgres - #14769

Merged
HarshMN2345 merged 2 commits into
appwrite:mainfrom
HarshMN2345:fix-postgres-healthcheck-init
Oct 23, 2026
Merged

HarshMN2345 merged 2 commits into
appwrite:mainfrom
HarshMN2345:fix-postgres-healthcheck-init

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

Postgres runs as PID 1 in the postgresql container. When a healthcheck run exceeds Docker's timeout, Docker kills the probe's shell and any child it left gets reparented to PID 1. Postmaster reaps it as an untracked child, and if it exited non-zero, postmaster terminates all backends and runs crash recovery. API calls fail with 500 general_unknown until recovery completes.

Reported on self-hosted 2.5.0 with PostgreSQL 18.3 under bursty TablesDB load.

This adds init: true to the postgresql service in docker-compose.yml and the console compose generator. Docker's init process becomes PID 1 and reaps orphans, so postmaster never sees them.

Tested with appwrite/postgres:0.1.0 and a healthcheck that leaves an orphan exiting with code 2: 5 crash restarts in 30s without init, none with --init.

… postmaster

A pg_isready probe that times out under load exits with code 2. With postmaster
as PID 1 it reaps the probe as an untracked child and restarts every backend.
Running an init process as PID 1 keeps the probes away from postmaster.
@appwrite

appwrite Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

New Console

Project ID: new-console

Sites (1)
Site Status Logs Preview QR
 New Console
new-console
Queued Queued Authorize Preview URL QR Code

Tip

Trigger functions via HTTP, SDKs, events, webhooks, or scheduled cron jobs

@HarshMN2345
HarshMN2345 marked this pull request as ready for review October 23, 2026 07:42
@ghost

ghost commented Oct 23, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The change is straightforward, but the existing installer compose-generator tests do not assert that the new init setting reaches rendered output.

This enables Docker Compose’s init process for PostgreSQL in the main stack and in the Console’s generated compose file. The init process can reap orphaned healthcheck children before they are adopted by Postgres.

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 Add a regression assertion for the installer output docker-compose.yml:1983
Fix with agent prompt
### Issue 1
docker-compose.yml:1983
**Add a regression assertion for the installer output**

The existing `GeneratorTest` renders this compose file and checks the PostgreSQL service, but it does not assert that `init` survives in the rendered install compose. If the setting is removed or lost during generator changes, those tests will still pass and self-hosted installs will miss this fix.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
📂 Walkthrough · 2
File Change
docker-compose.yml Enables Compose init for the PostgreSQL service in the main stack.
apps/console/src/lib/docs/compose-generator/composeData.ts Adds the same PostgreSQL init setting to the Console compose generator data.

Merged main (c922170); no changes to this PR's code since c445cb2 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

Comment thread docker-compose.yml
postgresql:
image: appwrite/postgres:0.1.0
container_name: appwrite-postgresql
init: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add a regression assertion for the installer output

The existing GeneratorTest renders this compose file and checks the PostgreSQL service, but it does not assert that init survives in the rendered install compose. If the setting is removed or lost during generator changes, those tests will still pass and self-hosted installs will miss this fix.

Prompt To Fix With AI
This is a comment left during a code review.
Path: docker-compose.yml
Line: 1983

Comment:
**Add a regression assertion for the installer output**

The existing `GeneratorTest` renders this compose file and checks the PostgreSQL service, but it does not assert that `init` survives in the rendered install compose. If the setting is removed or lost during generator changes, those tests will still pass and self-hosted installs will miss this fix.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · testing · Reply if this doesn't apply.

@HarshMN2345
HarshMN2345 merged commit c26afc9 into appwrite:main Oct 23, 2026
65 of 67 checks passed
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…hcheck-init

fix: run postgresql container with init so orphaned healthcheck processes don't crash postgres
(cherry picked from commit c26afc9)
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