|
26 | 26 | * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
27 | 27 | * Portions Copyright (c) 1994, Regents of the University of California
|
28 | 28 | *
|
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 $ |
30 | 30 | *
|
31 | 31 | *-------------------------------------------------------------------------
|
32 | 32 | */
|
@@ -321,13 +321,29 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
|
321 | 321 | intbshift=TransactionIdToBIndex(xid)*CLOG_BITS_PER_XACT;
|
322 | 322 | char*byteptr;
|
323 | 323 | charbyteval;
|
| 324 | +charcurval; |
324 | 325 |
|
325 | 326 | byteptr=ClogCtl->shared->page_buffer[slotno]+byteno;
|
| 327 | +curval= (*byteptr >>shift)&CLOG_XACT_BITMASK; |
326 | 328 |
|
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); |
331 | 347 |
|
332 | 348 | /* note this assumes exclusive access to the clog page */
|
333 | 349 | byteval=*byteptr;
|
|