Skip to content

TimescaleDB container runs out of shared memory under load #36

@dviejokfs

Description

@dviejokfs

Problem

TimescaleDB container crashes with shared memory error when running many deployed containers (~50+):

ERROR Database error: Query Error: error returned from database: could not resize shared memory segment "/PostgreSQL.577999938" to 16777216 bytes: No space left on device

Root Cause

Docker defaults /dev/shm to 64MB inside containers. PostgreSQL uses shared memory segments that grow with the number of connections. With many deployed apps hitting the database concurrently, the 64MB limit is exhausted.

Fix

Add --shm-size=2g to the TimescaleDB docker run command in both install scripts:

  • deploy.sh — full provisioning wizard
  • quick.sh — zero-prompt installer

Already applied to production by recreating the container with the flag. Scripts updated in the same PR.

Affected Users

Any self-hosted Temps instance with 30+ deployed applications can hit this. The error is intermittent — it depends on concurrent query load and PostgreSQL's dynamic shared memory allocation.

Workaround (existing installs)

# Recreate the container with larger shared memory (data preserved in volume)
docker stop temps-timescaledb
docker rm temps-timescaledb
docker run -d \
  --name temps-timescaledb \
  --restart unless-stopped \
  --shm-size=2g \
  -p 5432:5432 \
  -v temps-pgdata:/home/postgres/pgdata/data \
  -e POSTGRES_USER=temps \
  -e POSTGRES_PASSWORD="$(cat ~/.temps/.wizard-state/db_password)" \
  -e POSTGRES_DB=temps \
  timescale/timescaledb-ha:pg18

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions