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

Commitd698bf8

Browse files
committed
Fix TransactionIdSetStatusBit so that it doesn't try to change a transaction
from COMMITTED to SUBCOMMITTED during recovery. This wasn't previouslypossible, but it is now due to the recent changes on clog commit protocol forsubtransactions.Simon Riggs
1 parent13fc2e4 commitd698bf8

File tree

1 file changed

+21
-5
lines changed
  • src/backend/access/transam

1 file changed

+21
-5
lines changed

‎src/backend/access/transam/clog.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
2727
* Portions Copyright (c) 1994, Regents of the University of California
2828
*
29-
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.48 2008/10/20 19:18:18 alvherre Exp $
29+
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.49 2008/11/03 19:24:03 alvherre Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -321,13 +321,29 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
321321
intbshift=TransactionIdToBIndex(xid)*CLOG_BITS_PER_XACT;
322322
char*byteptr;
323323
charbyteval;
324+
charcurval;
324325

325326
byteptr=ClogCtl->shared->page_buffer[slotno]+byteno;
327+
curval= (*byteptr >>shift)&CLOG_XACT_BITMASK;
326328

327-
/* Current state should be 0, subcommitted or target state */
328-
Assert(((*byteptr >>bshift)&CLOG_XACT_BITMASK)==0||
329-
((*byteptr >>bshift)&CLOG_XACT_BITMASK)==TRANSACTION_STATUS_SUB_COMMITTED||
330-
((*byteptr >>bshift)&CLOG_XACT_BITMASK)==status);
329+
/*
330+
* When replaying transactions during recovery we still need to perform
331+
* the two phases of subcommit and then commit. However, some transactions
332+
* are already correctly marked, so we just treat those as a no-op which
333+
* allows us to keep the following Assert as restrictive as possible.
334+
*/
335+
if (InRecovery&&status==TRANSACTION_STATUS_SUB_COMMITTED&&
336+
curval==TRANSACTION_STATUS_COMMITTED)
337+
return;
338+
339+
/*
340+
* Current state change should be from 0 or subcommitted to target state
341+
* or we should already be there when replaying changes during recovery.
342+
*/
343+
Assert(curval==0||
344+
(curval==TRANSACTION_STATUS_SUB_COMMITTED&&
345+
status!=TRANSACTION_STATUS_IN_PROGRESS)||
346+
curval==status);
331347

332348
/* note this assumes exclusive access to the clog page */
333349
byteval=*byteptr;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp