Skip to content

Commit 9aa2e7d

Browse files
committed
Temporarily dike out GetUndoRecPtr() in checkpoint generation, since we
do not use the undo pointer anyway. This is a quick-hack solution for the three-way deadlock condition discussed in pghackers 17-Dec-01. Need to find a better way of doing it.
1 parent a51c7c4 commit 9aa2e7d

File tree

1 file changed

+18
-3
lines changed
  • src/backend/access/transam

1 file changed

+18
-3
lines changed

src/backend/access/transam/xlog.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.82 2001/11/05 17:46:24 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.83 2001/12/19 19:42:51 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -744,9 +744,13 @@ begin:;
744744
/* If first XLOG record of transaction, save it in PROC array */
745745
if (MyLastRecPtr.xrecoff == 0 && !no_tran)
746746
{
747-
LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
747+
/*
748+
* We do not acquire SInvalLock here because of possible deadlock.
749+
* Anyone who wants to inspect other procs' logRec must acquire
750+
* WALInsertLock, instead. A better solution would be a per-PROC
751+
* spinlock, but no time for that before 7.2 --- tgl 12/19/01.
752+
*/
748753
MyProc->logRec = RecPtr;
749-
LWLockRelease(SInvalLock);
750754
}
751755

752756
if (XLOG_DEBUG)
@@ -2928,11 +2932,22 @@ CreateCheckPoint(bool shutdown)
29282932
* this while holding insert lock to ensure that we won't miss any
29292933
* about-to-commit transactions (UNDO must include all xacts that have
29302934
* commits after REDO point).
2935+
*
2936+
* XXX temporarily ifdef'd out to avoid three-way deadlock condition:
2937+
* GetUndoRecPtr needs to grab SInvalLock to ensure that it is looking
2938+
* at a stable set of proc records, but grabbing SInvalLock while holding
2939+
* WALInsertLock is no good. GetNewTransactionId may cause a WAL record
2940+
* to be written while holding XidGenLock, and GetSnapshotData needs to
2941+
* get XidGenLock while holding SInvalLock, so there's a risk of deadlock.
2942+
* Need to find a better solution. See pgsql-hackers discussion of
2943+
* 17-Dec-01.
29312944
*/
2945+
#ifdef NOT_USED
29322946
checkPoint.undo = GetUndoRecPtr();
29332947

29342948
if (shutdown && checkPoint.undo.xrecoff != 0)
29352949
elog(STOP, "active transaction while database system is shutting down");
2950+
#endif
29362951

29372952
/*
29382953
* Now we can release insert lock, allowing other xacts to proceed

0 commit comments

Comments
 (0)