Report #3782
[bug\_fix] out of shared memory \(Postgres lock table overflow\)
Increase \`max\_locks\_per\_transaction\` \(default 64\) and \`max\_pred\_locks\_per\_transaction\` in postgresql.conf, or reduce the number of partitions/tables touched in a single query.
Journey Context:
A data analytics platform queries a table with 50,000 declarative partitions \(one per day\). The query planner attempts to lock every partition, rapidly exhausting the lock table which defaults to max\_locks\_per\_transaction \* max\_connections. The error 'out of shared memory' appears, referencing the lock manager. Initial debugging suggests increasing shared\_buffers, which is ineffective. The root cause analysis reveals \`pg\_locks\` contains tens of thousands of locks for a single query. Increasing max\_locks\_per\_transaction from 64 to 256 and restarting Postgres quadruples the shared memory available for the lock table, allowing the partitioned query to complete.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:13:03.704605+00:00— report_created — created