mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-09 08:10:09 +08:00
Tweaks for SSI out-of-shared memory behavior.
If we call hash_search() with HASH_ENTER, it will bail out rather than return NULL, so it's redundant to check for NULL again in the caller. Thus, in cases where we believe it's impossible for the hash table to run out of slots anyway, we can simplify the code slightly. On the flip side, in cases where it's theoretically possible to run out of space, we don't want to rely on dynahash.c to throw an error; instead, we pass HASH_ENTER_NULL and throw the error ourselves if a NULL comes back, so that we can provide a more descriptive error message. Kevin Grittner
This commit is contained in:
parent
73d9a90814
commit
56c7140ca8
@ -1604,12 +1604,7 @@ RegisterPredicateLockingXid(const TransactionId xid)
|
|||||||
sxid = (SERIALIZABLEXID *) hash_search(SerializableXidHash,
|
sxid = (SERIALIZABLEXID *) hash_search(SerializableXidHash,
|
||||||
&sxidtag,
|
&sxidtag,
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER, &found);
|
||||||
if (!sxid)
|
Assert(sxid != NULL);
|
||||||
/* This should not be possible, based on allocation. */
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
|
||||||
errmsg("out of shared memory")));
|
|
||||||
|
|
||||||
Assert(!found);
|
Assert(!found);
|
||||||
|
|
||||||
/* Initialize the structure. */
|
/* Initialize the structure. */
|
||||||
@ -2045,7 +2040,7 @@ CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
|
|||||||
target = (PREDICATELOCKTARGET *)
|
target = (PREDICATELOCKTARGET *)
|
||||||
hash_search_with_hash_value(PredicateLockTargetHash,
|
hash_search_with_hash_value(PredicateLockTargetHash,
|
||||||
targettag, targettaghash,
|
targettag, targettaghash,
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER_NULL, &found);
|
||||||
if (!target)
|
if (!target)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
@ -2060,7 +2055,7 @@ CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
|
|||||||
lock = (PREDICATELOCK *)
|
lock = (PREDICATELOCK *)
|
||||||
hash_search_with_hash_value(PredicateLockHash, &locktag,
|
hash_search_with_hash_value(PredicateLockHash, &locktag,
|
||||||
PredicateLockHashCodeFromTargetHashCode(&locktag, targettaghash),
|
PredicateLockHashCodeFromTargetHashCode(&locktag, targettaghash),
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER_NULL, &found);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
@ -3251,7 +3246,7 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
|
|||||||
predlock = hash_search_with_hash_value(PredicateLockHash, &tag,
|
predlock = hash_search_with_hash_value(PredicateLockHash, &tag,
|
||||||
PredicateLockHashCodeFromTargetHashCode(&tag,
|
PredicateLockHashCodeFromTargetHashCode(&tag,
|
||||||
targettaghash),
|
targettaghash),
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER_NULL, &found);
|
||||||
if (!predlock)
|
if (!predlock)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
@ -4301,10 +4296,7 @@ predicatelock_twophase_recover(TransactionId xid, uint16 info,
|
|||||||
sxid = (SERIALIZABLEXID *) hash_search(SerializableXidHash,
|
sxid = (SERIALIZABLEXID *) hash_search(SerializableXidHash,
|
||||||
&sxidtag,
|
&sxidtag,
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER, &found);
|
||||||
if (!sxid)
|
Assert(sxid != NULL);
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
|
||||||
errmsg("out of shared memory")));
|
|
||||||
Assert(!found);
|
Assert(!found);
|
||||||
sxid->myXact = (SERIALIZABLEXACT *) sxact;
|
sxid->myXact = (SERIALIZABLEXACT *) sxact;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user