PostgreSQL lightweight-lock manager, with its interface in src/include/storage/lwlock.h, is a facility aimed at controlling the access to shared memory data structures. One set of routines is at the center of this post: LWLockUpdateVar() LWLockWaitForVar() LWLockReleaseClearVar() These are the least popular APIs related to lightweight locks used in the PostgreSQL core code, being only used by the WAL insertion code to control the locking around the backends doing the insertion of WAL records ...