Re: Shared hash table allocations
Heikki Linnakangas <hlinnaka@iki.fi>
On 03/04/2026 16:03, Ashutosh Bapat wrote: > On Thu, Apr 2, 2026 at 10:15 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote: >>> I think the release notes should "nudge" all the >>> users who use non-default max_locks_per_transaction to increase it if >>> they see "out of memory" errors. I don't think it should provide a >>> blanket advise to double their locks >> >> How about: >> >> "If you had previously set max_locks_per_transaction, you might need to >> set it to a higher value in v19 to avoid "out of shared memory" errors. >> If you are unsure what to set it to and don't mind the increased memory >> usage, you can double the value to ensure that you can acquire at least >> as many locks as before" > > The wiggle room is 100KB fixed + 10% of other two structures, so value > by which it should be increased is partly fixed and partly a multiple > of current value. "double the value" is simplest advice we can give. > +1. Ok, committed these patches to remove the safety margins, make LOCK and PROCLOCK fixed-size, and change the default to max_locks_per_transaction=128. I will do one final self-review of the remaining earlier patches from this thread next; I believe they're ready to be committed too. Thanks for the review! - Heikki
Commits
-
Remove HASH_DIRSIZE, always use the default algorithm to select it
- 4953a25b7f3b 19 (unreleased) landed
-
Allocate all parts of shmem hash table from a single contiguous area
- 9fe9ecd516b0 19 (unreleased) landed
-
Prevent shared memory hash tables from growing beyond initial size
- 999e9ebb51c9 19 (unreleased) landed
-
Merge init and max size options on shmem hash tables
- 9ebe1c4f2c7c 19 (unreleased) landed
-
Change default of max_locks_per_transactions to 128
- 79534f90657c 19 (unreleased) landed
-
Make the lock hash tables fixed-sized
- e1ad034809a4 19 (unreleased) landed
-
Remove 10% safety margin from lock manager hash table estimates
- 3e854d2ff1a6 19 (unreleased) landed
-
Remove bogus "safety margin" from predicate.c shmem estimates
- feb03dfecdc9 19 (unreleased) landed
-
Make ShmemIndex visible in the pg_shmem_allocations view
- 1bdbb211bbf3 19 (unreleased) landed
-
Change the signature of dynahash's alloc function
- 7b424e3108e4 19 (unreleased) landed
-
Remove HASH_SEGMENT option
- dde69621c324 19 (unreleased) landed
-
Use ShmemInitStruct to allocate shmem for semaphores
- 40c41dc77306 19 (unreleased) landed