Allocate all entries in the serializable xid hash up-front, so that you don't

run out of shared memory when you try to assign an xid to a transaction.

Kevin Grittner
This commit is contained in:
Heikki Linnakangas 2011-02-10 12:00:53 +02:00
parent 2ad0348677
commit cecb5901b8
1 changed files with 3 additions and 5 deletions

View File

@ -1018,7 +1018,6 @@ InitPredicateLocks(void)
* PredicateLockShmemSize! * PredicateLockShmemSize!
*/ */
max_table_size = (MaxBackends + max_prepared_xacts); max_table_size = (MaxBackends + max_prepared_xacts);
init_table_size = max_table_size / 2;
/* /*
* Allocate a list to hold information on transactions participating in * Allocate a list to hold information on transactions participating in
@ -1029,7 +1028,6 @@ InitPredicateLocks(void)
* be summarized for storage in SLRU and the "dummy" transaction. * be summarized for storage in SLRU and the "dummy" transaction.
*/ */
max_table_size *= 10; max_table_size *= 10;
init_table_size *= 10;
PredXact = ShmemInitStruct("PredXactList", PredXact = ShmemInitStruct("PredXactList",
PredXactListDataSize, PredXactListDataSize,
@ -1092,7 +1090,7 @@ InitPredicateLocks(void)
hash_flags = (HASH_ELEM | HASH_FUNCTION); hash_flags = (HASH_ELEM | HASH_FUNCTION);
SerializableXidHash = ShmemInitHash("SERIALIZABLEXID hash", SerializableXidHash = ShmemInitHash("SERIALIZABLEXID hash",
init_table_size, max_table_size,
max_table_size, max_table_size,
&info, &info,
hash_flags); hash_flags);
@ -1595,10 +1593,10 @@ RegisterPredicateLockingXid(const TransactionId xid)
&sxidtag, &sxidtag,
HASH_ENTER, &found); HASH_ENTER, &found);
if (!sxid) if (!sxid)
/* This should not be possible, based on allocation. */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of shared memory"), errmsg("out of shared memory")));
errhint("You might need to increase max_predicate_locks_per_transaction.")));
Assert(!found); Assert(!found);