Improve GrantLockLocal() handling on out-of-memory errors On the first LockAcquire for a lock tag, LockAcquireExtended() creates a LOCALLOCK entry in the hash table LockMethodLocalHash, with lockOwners set to NULL. lockOwners is then allocated in TopMemoryContext.
If the allocation fails, the hash entry would persist with lockOwners still NULL and maxLockOwners already set to 8. A follow-up LockAcquire() on the same entry would crash on a NULL pointer dereference. This commit adds an extra layer of safety for such a case, by re-attempting MemoryContextAlloc() if a LOCALLOCK entry exists but its lockOwners is still NULL due to a previous in-flight allocation failure. This problem is unlikely going to show up in practice, so no backpatch is done. Author: Bryan Green <[email protected]> Author: Mark Dilger <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/afd63e0ad23ed826aa953977a5306a3703503afa Modified Files -------------- src/backend/storage/lmgr/lock.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
