Skip to content

Continuous memory growth and OOM kills since PostgREST v13+ #4462

@bolinocroustibat

Description

@bolinocroustibat

Description

After upgrading from PostgREST v12.2.3v13.0.8 and v14.0.0, we observe a reproducible memory issue in production:
RAM usage continuously increases over time until the process is killed by the OOM killer.
This regression does not occur with v12, where memory usage remains stable even under heavy load.

Context

We run PostgREST as part of a public API gateway (tabular-api.data.gouv.fr), which dynamically exposes a large PostgreSQL database (tens of thousands of tables).
Each dataset in the DB corresponds to one physical table, so the total number of tables can vary — currently around 55K, but previously up to 120K.

PostgREST is deployed via Nomad/Consul (Blue/Green deployments, 2 instances, 6–8 GB RAM each).

Observed behavior

  • With v13+, memory usage starts around 25–50% at startup and grows steadily until the process reaches 100% and is OOM-killed (every 1–2 hours under load).
  • With v12.2.3, memory usage may start higher, but remains stable over time under identical load and schema size.
  • Reducing the number of tables (from 120K → 55K) does not change the behavior.
  • Restarting PostgREST temporarily resets memory, but the same growth pattern repeats.
Image

Positive change since v14

Startup appears very significantly smoother and faster in v14+ — lower initial RAM consumption and faster readiness.
However, this comes at the cost of continuous memory growth over time at least for v13+, which was not observed in previous releases.

What we’ve tried

  • Increasing PostgREST memory allocation (6 GB → 8 GB): no effect, still OOM after a few hours.
  • Purging half of the tables: no effect.
  • Reverting to v12.2.3: memory stable again, no OOM.

Environment

  • PostgreSQL: 15.8 (Debian package)
  • PostgREST versions tested:
    • ✅ 12.2.3 — stable memory behavior
    • ❌ 13.0.8 — continuous memory growth → OOM
    • ❌ 14.0.0 — same issue
  • Deployment: Nomad + Consul (Blue/Green, 2 instances, 6–8 GB RAM each)
  • Approx. tables: ~55,000
  • Approx. requests: hundreds/minute (read-only)

Expected behavior

Memory usage should stay stable over time after startup, as in previous versions.

Actual behavior

Memory usage keeps increasing until the process is terminated by the system OOM killer.

Notes

This may be related to caching or schema metadata management changes introduced in v13+?

EDIT: Separately, we reported an issue where queries to some recently created tables fail with ServerDisconnectedError starting in v13.
We are not sure whether both problems share a common cause, but both regressions vanish when reverting to v12.

Happy to provide detailed metrics or logs if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions