mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Whoops, I was a tad too enthusiastic about using shared lock mode for
SInvalLock. GetSnapshotData(true) has to use exclusive lock, since it sets MyProc->xmin.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.41 2001/09/29 04:02:24 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.42 2001/09/29 15:29:48 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -310,19 +310,24 @@ GetSnapshotData(bool serializable)
|
|||||||
if (snapshot == NULL)
|
if (snapshot == NULL)
|
||||||
elog(ERROR, "Memory exhausted in GetSnapshotData");
|
elog(ERROR, "Memory exhausted in GetSnapshotData");
|
||||||
|
|
||||||
snapshot->xmin = GetCurrentTransactionId();
|
|
||||||
|
|
||||||
LWLockAcquire(SInvalLock, LW_SHARED);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There can be no more than lastBackend active transactions, so this
|
* Allocating space for MaxBackends xids is usually overkill;
|
||||||
* is enough space:
|
* lastBackend would be sufficient. But it seems better to do the
|
||||||
|
* malloc while not holding the lock, so we can't look at lastBackend.
|
||||||
*/
|
*/
|
||||||
snapshot->xip = (TransactionId *)
|
snapshot->xip = (TransactionId *)
|
||||||
malloc(segP->lastBackend * sizeof(TransactionId));
|
malloc(MaxBackends * sizeof(TransactionId));
|
||||||
if (snapshot->xip == NULL)
|
if (snapshot->xip == NULL)
|
||||||
elog(ERROR, "Memory exhausted in GetSnapshotData");
|
elog(ERROR, "Memory exhausted in GetSnapshotData");
|
||||||
|
|
||||||
|
snapshot->xmin = GetCurrentTransactionId();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are going to set MyProc->xmin then we'd better get exclusive
|
||||||
|
* lock; if not, this is a read-only operation so it can be shared.
|
||||||
|
*/
|
||||||
|
LWLockAcquire(SInvalLock, serializable ? LW_EXCLUSIVE : LW_SHARED);
|
||||||
|
|
||||||
/*--------------------
|
/*--------------------
|
||||||
* Unfortunately, we have to call ReadNewTransactionId() after acquiring
|
* Unfortunately, we have to call ReadNewTransactionId() after acquiring
|
||||||
* SInvalLock above. It's not good because ReadNewTransactionId() does
|
* SInvalLock above. It's not good because ReadNewTransactionId() does
|
||||||
|
Reference in New Issue
Block a user