Skip to content

fix: give postgresql 1g of shared memory - #14451

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/postgres-shm-size
Oct 13, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/postgres-shm-size

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Adds shm_size: 1g to the postgresql service in docker-compose.yml. The installer and the docs compose generator both render from that file, so new installs and updates pick it up. The docs composeData.ts is regenerated to match.

Why

Docker gives each container only 64 MB of /dev/shm by default. On larger self-hosted instances, Postgres 18 needs more than that for dynamic shared memory and fails during startup:

FATAL: could not resize shared memory segment "/PostgreSQL.2087567546" to 33554432 bytes: No space left on device
LOG: aborting startup due to startup process failure

Because Postgres never comes up, the appwrite container never becomes healthy, and the 2.5.0 update installer fails with "Failed to connect with Appwrite in time. Could not resolve host: appwrite".

/dev/shm is a tmpfs, so 1g is a ceiling, not a reservation. It only uses memory that Postgres actually writes.

Test plan

  • docker compose config -q passes
  • Regenerated the console compose data with bun run scripts/generate-compose-data.ts

Workaround for affected users: add shm_size: 1g under postgresql: in ~/appwrite/docker-compose.yml, then run docker compose up -d.

Related: #14424

Docker caps /dev/shm at 64 MB, which Postgres 18 outgrows on larger instances. It then fails crash recovery with 'could not resize shared memory segment: No space left on device', and the update installer times out waiting for Appwrite.
@luxor-code-review

luxor-code-review Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review complete. No issues found.


This PR increases PostgreSQL shared memory by adding a shm_size: 1g entry to the appwrite-postgresql service, preventing shared-memory exhaustion errors in Postgres 13+ under load, and keeps the console's compose-generator template in exact parity so generated install files match the canonical compose file.

Files Change
docker-compose.yml Adds shm_size: 1g to the appwrite-postgresql service definition.
apps/console/src/lib/docs/compose-generator/composeData.ts Mirrors the same shm_size: 1g block in the embedded generated-compose template so the generator output stays in parity.

Reviewed commit: e0894b0

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 13, 2026
@ghost

ghost commented Oct 13, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The shared-memory configuration and generator serialization changes preserve the generated values and do not introduce a correctness issue.

The PostgreSQL service now has a 1 GiB shared-memory limit in the primary Compose configuration, and the docs compose data includes the same setting. The compose-data generator now emits multiline values as readable template literals and formats its output with the Console's Prettier configuration.

1 of 2 changed files was too large to include in full.

Latest changes: The newest commits update the compose-data generator to serialize multiline values as escaped template literals and run Prettier on the generated TypeScript.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

Part of the diff was too large to review, so Hansi did not approve.

📂 Walkthrough · 3
File Change
docker-compose.yml Sets the PostgreSQL service shared-memory limit to 1 GiB.
apps/console/scripts/generate-compose-data.ts Updates generated-value serialization to use template literals for multiline content and formats the generated TypeScript with Prettier.
apps/console/src/lib/docs/compose-generator/composeData.ts Regenerates the docs compose data with the PostgreSQL shared-memory setting and readable multiline values.

Reviewed the commits since e0894b0 · 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 S · Looks good to merge. Summary

The generator wrote every YAML block as one escaped JSON string, so the file had 7,000-character lines and diffs were unreadable. Multi-line strings are now template literals, and the output is run through Prettier. Every exported value is unchanged.
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k
ChiragAgg5k merged commit 2ce24ce into main Oct 13, 2026
13 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/postgres-shm-size branch October 13, 2026 15:37
@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/postgres-shm-size (after).

Metric Before After Change
🚀 Requests/sec 218.81 222.67 ⚪ +1.8%
⏱️ Latency P50 79.56 ms 77.87 ms ⚪ -2.1%
⏱️ Latency P95 183.24 ms 182.05 ms ⚪ -0.6%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 77.87 182.05 13,680 222.67 -1.18
Account 149.38 288.43 720 12.45 +29.52
TablesDB 75.2 129.97 7,440 123.78 -6.66
Storage 71.39 146.77 3,600 61.45 -26.81
Functions 118.98 236.41 1,920 33.59 +29.01

Top API waits (after)

API request Max wait (ms)
account.name.update 438.42
tokens.delete 420.96
account.prefs.update 406.93
functions.create 371.5
functions.variables.update 365.96

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