diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/storage/ipc/ipci.c | 4 | ||||
-rw-r--r-- | src/backend/storage/lmgr/lock.c | 35 | ||||
-rw-r--r-- | src/backend/utils/init/postinit.c | 3 |
3 files changed, 22 insertions, 20 deletions
diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index 35fa2e1dda6..8f8a89124e8 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -116,7 +116,7 @@ CalculateShmemSize(int *num_semaphores) size = add_size(size, dsm_estimate_size()); size = add_size(size, DSMRegistryShmemSize()); size = add_size(size, BufferShmemSize()); - size = add_size(size, LockShmemSize()); + size = add_size(size, LockManagerShmemSize()); size = add_size(size, PredicateLockShmemSize()); size = add_size(size, ProcGlobalShmemSize()); size = add_size(size, XLogPrefetchShmemSize()); @@ -291,7 +291,7 @@ CreateOrAttachShmemStructs(void) /* * Set up lock manager */ - InitLocks(); + LockManagerShmemInit(); /* * Set up predicate lock manager diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 0400a507779..6dbc41dae70 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -377,19 +377,17 @@ static void GetSingleProcBlockerStatusData(PGPROC *blocked_proc, /* - * InitLocks -- Initialize the lock manager's data structures. + * Initialize the lock manager's shmem data structures. * - * This is called from CreateSharedMemoryAndSemaphores(), which see for - * more comments. In the normal postmaster case, the shared hash tables - * are created here, as well as a locallock hash table that will remain - * unused and empty in the postmaster itself. Backends inherit the pointers - * to the shared tables via fork(), and also inherit an image of the locallock - * hash table, which they proceed to use. In the EXEC_BACKEND case, each - * backend re-executes this code to obtain pointers to the already existing - * shared hash tables and to create its locallock hash table. + * This is called from CreateSharedMemoryAndSemaphores(), which see for more + * comments. In the normal postmaster case, the shared hash tables are + * created here, and backends inherit pointers to them via fork(). In the + * EXEC_BACKEND case, each backend re-executes this code to obtain pointers to + * the already existing shared hash tables. In either case, each backend must + * also call InitLockManagerAccess() to create the locallock hash table. */ void -InitLocks(void) +LockManagerShmemInit(void) { HASHCTL info; long init_table_size, @@ -444,18 +442,19 @@ InitLocks(void) sizeof(FastPathStrongRelationLockData), &found); if (!found) SpinLockInit(&FastPathStrongRelationLocks->mutex); +} +/* + * Initialize the lock manager's backend-private data structures. + */ +void +InitLockManagerAccess(void) +{ /* * Allocate non-shared hash table for LOCALLOCK structs. This stores lock * counts and resource owner information. - * - * The non-shared table could already exist in this process (this occurs - * when the postmaster is recreating shared memory after a backend crash). - * If so, delete and recreate it. (We could simply leave it, since it - * ought to be empty in the postmaster, but for safety let's zap it.) */ - if (LockMethodLocalHash) - hash_destroy(LockMethodLocalHash); + HASHCTL info; info.keysize = sizeof(LOCALLOCKTAG); info.entrysize = sizeof(LOCALLOCK); @@ -3571,7 +3570,7 @@ PostPrepare_Locks(TransactionId xid) * Estimate shared-memory space used for lock tables */ Size -LockShmemSize(void) +LockManagerShmemSize(void) { Size size = 0; long max_table_size; diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 13524ea488a..04a47d6e704 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -606,6 +606,9 @@ BaseInit(void) */ InitXLogInsert(); + /* Initialize lock manager's local structs */ + InitLockManagerAccess(); + /* * Initialize replication slots after pgstat. The exit hook might need to * drop ephemeral slots, which in turn triggers stats reporting. |