diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index a02a69f..7665860 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -88,8 +88,7 @@ static void WriteZeroPageXlogRec(int pageno); static void WriteTruncateXlogRec(int pageno); static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids, TransactionId *subxids, XidStatus status, - XLogRecPtr lsn, int pageno, - bool all_xact_same_page); + XLogRecPtr lsn, int pageno); static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, int slotno); static void set_status_by_pages(int nsubxids, TransactionId *subxids, @@ -181,7 +180,7 @@ TransactionIdSetTreeStatus(TransactionId xid, int nsubxids, * Set the parent and all subtransactions in a single call */ TransactionIdSetPageStatus(xid, nsubxids, subxids, status, lsn, - pageno, true); + pageno); } else { @@ -208,7 +207,7 @@ TransactionIdSetTreeStatus(TransactionId xid, int nsubxids, */ pageno = TransactionIdToPage(xid); TransactionIdSetPageStatus(xid, nsubxids_on_first_page, subxids, status, - lsn, pageno, false); + lsn, pageno); /* * Now work through the rest of the subxids one clog page at a time, @@ -246,7 +245,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids, TransactionIdSetPageStatus(InvalidTransactionId, num_on_page, subxids + offset, - status, lsn, pageno, false); + status, lsn, pageno); offset = i; pageno = TransactionIdToPage(subxids[offset]); } @@ -260,25 +259,18 @@ set_status_by_pages(int nsubxids, TransactionId *subxids, * updates; a single leader process will perform transaction status updates * for multiple backends so that the number of times CLogControlLock needs * to be acquired is reduced. We don't try to do this if a process has - * overflowed the subxids array in its PGPROC, since in that case we - * don't have a complete list of XIDs for it. We also skip it if a process - * has XIDs on more than one CLOG page, or on a different CLOG page than - * processes already waiting for a group update. This latter condition - * has a race condition (see TransactionGroupUpdateXidStatus) but the - * worst thing that happens if we mess up is a small loss of efficiency; - * the intent is to avoid having the leader access pages it wouldn't - * otherwise need to touch. Finally, we skip it for prepared transactions, - * which don't have the semaphore we would need for this optimization, - * and which are anyway probably not all that common. + * subxids, since in that case we need to advertise the complete list of + * subxids of each proc. We can't rely on subxids in PGPROC for rollback and + * rollback to savepoint. We also skip it for prepared transactions, which + * don't have the semaphore we would need for this optimization, and which are + * anyway probably not all that common. */ static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids, TransactionId *subxids, XidStatus status, - XLogRecPtr lsn, int pageno, - bool all_xact_same_page) + XLogRecPtr lsn, int pageno) { - if (all_xact_same_page && - nsubxids < PGPROC_MAX_CACHED_SUBXIDS && + if (nsubxids <= 0 && !IsGXactActive()) { /* @@ -289,14 +281,14 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids, */ if (LWLockConditionalAcquire(CLogControlLock, LW_EXCLUSIVE)) { - TransactionIdSetPageStatusInternal(xid, nsubxids, subxids, status, lsn, pageno); + TransactionIdSetPageStatusInternal(xid, 0, NULL, status, lsn, pageno); LWLockRelease(CLogControlLock); } else if (!TransactionGroupUpdateXidStatus(xid, status, lsn, pageno)) { LWLockAcquire(CLogControlLock, LW_EXCLUSIVE); - TransactionIdSetPageStatusInternal(xid, nsubxids, subxids, status, lsn, pageno); + TransactionIdSetPageStatusInternal(xid, 0, NULL, status, lsn, pageno); LWLockRelease(CLogControlLock); } @@ -491,15 +483,9 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status, PGPROC *proc = &ProcGlobal->allProcs[nextidx]; PGXACT *pgxact = &ProcGlobal->allPgXact[nextidx]; - /* - * Overflowed transactions should not use group XID status update - * mechanism. - */ - Assert(!pgxact->overflowed); - TransactionIdSetPageStatusInternal(proc->clogGroupMemberXid, - pgxact->nxids, - proc->subxids.xids, + 0, + NULL, proc->clogGroupMemberXidStatus, proc->clogGroupMemberLsn, proc->clogGroupMemberPage);