Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a314ad

Browse files
committed
Whoops, I was a tad too enthusiastic about using shared lock mode for
SInvalLock. GetSnapshotData(true) has to use exclusive lock, sinceit sets MyProc->xmin.
1 parent6fdf7be commit2a314ad

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

‎src/backend/storage/ipc/sinval.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.41 2001/09/2904:02:24 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.42 2001/09/2915:29:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -310,19 +310,24 @@ GetSnapshotData(bool serializable)
310310
if (snapshot==NULL)
311311
elog(ERROR,"Memory exhausted in GetSnapshotData");
312312

313-
snapshot->xmin=GetCurrentTransactionId();
314-
315-
LWLockAcquire(SInvalLock,LW_SHARED);
316-
317313
/*
318-
* There can be no more than lastBackend active transactions, so this
319-
* is enough space:
314+
* Allocating space for MaxBackends xids is usually overkill;
315+
* lastBackend would be sufficient. But it seems better to do the
316+
* malloc while not holding the lock, so we can't look at lastBackend.
320317
*/
321318
snapshot->xip= (TransactionId*)
322-
malloc(segP->lastBackend*sizeof(TransactionId));
319+
malloc(MaxBackends*sizeof(TransactionId));
323320
if (snapshot->xip==NULL)
324321
elog(ERROR,"Memory exhausted in GetSnapshotData");
325322

323+
snapshot->xmin=GetCurrentTransactionId();
324+
325+
/*
326+
* If we are going to set MyProc->xmin then we'd better get exclusive
327+
* lock; if not, this is a read-only operation so it can be shared.
328+
*/
329+
LWLockAcquire(SInvalLock,serializable ?LW_EXCLUSIVE :LW_SHARED);
330+
326331
/*--------------------
327332
* Unfortunately, we have to call ReadNewTransactionId() after acquiring
328333
* SInvalLock above. It's not good because ReadNewTransactionId() does

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp