diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 232f212a430..113457cbd0e 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -804,6 +804,7 @@ OldSerXidInit(void) oldSerXidControl = (OldSerXidControl) ShmemInitStruct("OldSerXidControlData", sizeof(OldSerXidControlData), &found); + Assert(found == IsUnderPostmaster); if (!found) { /* @@ -1099,6 +1100,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! @@ -1122,16 +1127,22 @@ InitPredicateLocks(void) &info, hash_flags); - /* 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 @@ -1144,6 +1155,9 @@ InitPredicateLocks(void) info.num_partitions = NUM_PREDICATELOCK_PARTITIONS; hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION | HASH_FIXED_SIZE); + /* Assume an average of 2 xacts per target */ + max_table_size *= 2; + PredicateLockHash = ShmemInitHash("PREDICATELOCK hash", max_table_size, max_table_size, @@ -1169,6 +1183,7 @@ InitPredicateLocks(void) PredXact = ShmemInitStruct("PredXactList", PredXactListDataSize, &found); + Assert(found == IsUnderPostmaster); if (!found) { int i; @@ -1248,6 +1263,7 @@ InitPredicateLocks(void) RWConflictPool = ShmemInitStruct("RWConflictPool", RWConflictPoolHeaderDataSize, &found); + Assert(found == IsUnderPostmaster); if (!found) { int i; @@ -1279,6 +1295,7 @@ InitPredicateLocks(void) ShmemInitStruct("FinishedSerializableTransactions", sizeof(SHM_QUEUE), &found); + Assert(found == IsUnderPostmaster); if (!found) SHMQueueInit(FinishedSerializableTransactions); @@ -1287,10 +1304,6 @@ InitPredicateLocks(void) * transactions. */ OldSerXidInit(); - - /* Pre-calculate the hash and partition lock of the scratch entry */ - ScratchTargetTagHash = PredicateLockTargetTagHashCode(&ScratchTargetTag); - ScratchPartitionLock = PredicateLockHashPartitionLock(ScratchTargetTagHash); } /*