diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index a4cb4d33add..74e4b35837b 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -815,6 +815,7 @@ OldSerXidInit(void) oldSerXidControl = (OldSerXidControl) ShmemInitStruct("OldSerXidControlData", sizeof(OldSerXidControlData), &found); + Assert(found == IsUnderPostmaster); if (!found) { /* @@ -1109,6 +1110,10 @@ InitPredicateLocks(void) Size requestSize; bool found; +#ifndef EXEC_BACKEND + Assert(!IsUnderPostmaster); +#endif + /* * Compute size of predicate lock target hashtable. Note these * calculations must agree with PredicateLockShmemSize! @@ -1131,16 +1136,22 @@ InitPredicateLocks(void) HASH_ELEM | HASH_BLOBS | HASH_PARTITION | HASH_FIXED_SIZE); - /* Assume an average of 2 xacts per target */ - max_table_size *= 2; - /* * Reserve a dummy entry in the hash table; we use it to make sure there's * always one entry available when we need to split or combine a page, * because running out of space there could mean aborting a * non-serializable transaction. */ - hash_search(PredicateLockTargetHash, &ScratchTargetTag, HASH_ENTER, NULL); + if (!IsUnderPostmaster) + { + (void) hash_search(PredicateLockTargetHash, &ScratchTargetTag, + HASH_ENTER, &found); + Assert(!found); + } + + /* Pre-calculate the hash and partition lock of the scratch entry */ + ScratchTargetTagHash = PredicateLockTargetTagHashCode(&ScratchTargetTag); + ScratchPartitionLock = PredicateLockHashPartitionLock(ScratchTargetTagHash); /* * Allocate hash table for PREDICATELOCK structs. This stores per @@ -1152,6 +1163,9 @@ InitPredicateLocks(void) info.hash = predicatelock_hash; info.num_partitions = NUM_PREDICATELOCK_PARTITIONS; + /* Assume an average of 2 xacts per target */ + max_table_size *= 2; + PredicateLockHash = ShmemInitHash("PREDICATELOCK hash", max_table_size, max_table_size, @@ -1178,6 +1192,7 @@ InitPredicateLocks(void) PredXact = ShmemInitStruct("PredXactList", PredXactListDataSize, &found); + Assert(found == IsUnderPostmaster); if (!found) { int i; @@ -1250,6 +1265,7 @@ InitPredicateLocks(void) RWConflictPool = ShmemInitStruct("RWConflictPool", RWConflictPoolHeaderDataSize, &found); + Assert(found == IsUnderPostmaster); if (!found) { int i; @@ -1275,6 +1291,7 @@ InitPredicateLocks(void) ShmemInitStruct("FinishedSerializableTransactions", sizeof(SHM_QUEUE), &found); + Assert(found == IsUnderPostmaster); if (!found) SHMQueueInit(FinishedSerializableTransactions); @@ -1283,10 +1300,6 @@ InitPredicateLocks(void) * transactions. */ OldSerXidInit(); - - /* Pre-calculate the hash and partition lock of the scratch entry */ - ScratchTargetTagHash = PredicateLockTargetTagHashCode(&ScratchTargetTag); - ScratchPartitionLock = PredicateLockHashPartitionLock(ScratchTargetTagHash); } /*