Commit cecb5901 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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
parent 2ad03486
...@@ -1018,7 +1018,6 @@ InitPredicateLocks(void) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment