On Thu, 2008-10-23 at 19:37 +0100, Simon Riggs wrote: > I suggest a third version with these changes: > > * Write the SUBCOMMITTED to COMMIT transition as a no-op during redo > rather than as an Assert. This prevents a transition from COMMIT to > SUBCOMMIT to ABORT. By making it a no-op the attempt to set COMMIT to > SUBCOMMIT never causes a failure, but it doesn't take place either. > > * Disallow SUBCOMMITTED to IN_PROGRESS transition via an Assert.
Even better idea: just use the InRecovery flag. Patch enclosed. Comments please. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support
Index: src/backend/access/transam/clog.c =================================================================== RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/access/transam/clog.c,v retrieving revision 1.48 diff -c -r1.48 clog.c *** src/backend/access/transam/clog.c 20 Oct 2008 19:18:18 -0000 1.48 --- src/backend/access/transam/clog.c 27 Oct 2008 21:15:00 -0000 *************** *** 324,332 **** byteptr = ClogCtl->shared->page_buffer[slotno] + byteno; ! /* Current state should be 0, subcommitted or target state */ Assert(((*byteptr >> bshift) & CLOG_XACT_BITMASK) == 0 || ! ((*byteptr >> bshift) & CLOG_XACT_BITMASK) == TRANSACTION_STATUS_SUB_COMMITTED || ((*byteptr >> bshift) & CLOG_XACT_BITMASK) == status); /* note this assumes exclusive access to the clog page */ --- 324,346 ---- byteptr = ClogCtl->shared->page_buffer[slotno] + byteno; ! /* ! * When replaying transactions during recovery we still need to perform ! * the two phases of subcommit and then commit. However, some transactions ! * are already correctly marked, so we just treat those as a no-op which ! * allows us to keep the following Assert as restrictive as possible. ! */ ! if (InRecovery && status == TRANSACTION_STATUS_SUB_COMMITTED && ! ((*byteptr >> bshift) & CLOG_XACT_BITMASK) == TRANSACTION_STATUS_COMMITTED) ! return; ! ! /* ! * Current state change should be from 0 or subcommitted to target state ! * or we should already be there when replaying changes during recovery. ! */ Assert(((*byteptr >> bshift) & CLOG_XACT_BITMASK) == 0 || ! (((*byteptr >> bshift) & CLOG_XACT_BITMASK) == TRANSACTION_STATUS_SUB_COMMITTED && ! status != TRANSACTION_STATUS_IN_PROGRESS) || ((*byteptr >> bshift) & CLOG_XACT_BITMASK) == status); /* note this assumes exclusive access to the clog page */
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers