From d4793993df81fc5086c58042f8ed9a719e633a91 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Mon, 5 Oct 2009 13:43:01 +0100 Subject: [PATCH] Apply Heikki's changes to replace RecordKnownAssignedTransactionIds() back to the way it was in November 2008. Hey ho. Patch 0014-Call-RecordKnownAssignedTransactionIds-once-just-bef.patch --- src/backend/access/gin/ginxlog.c | 2 -- src/backend/access/gist/gistxlog.c | 9 +++------ src/backend/access/heap/heapam.c | 10 ++-------- src/backend/access/nbtree/nbtxlog.c | 1 - src/backend/access/transam/clog.c | 3 --- src/backend/access/transam/xact.c | 28 +++++++--------------------- src/backend/access/transam/xlog.c | 7 ++++--- src/backend/catalog/storage.c | 3 --- src/backend/commands/dbcommands.c | 8 -------- src/backend/commands/sequence.c | 3 --- src/backend/commands/tablespace.c | 12 ------------ src/backend/storage/ipc/procarray.c | 6 ------ src/backend/utils/cache/inval.c | 10 +++++----- 13 files changed, 21 insertions(+), 81 deletions(-) diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c index 46cc5f1792..d06cee6430 100644 --- a/src/backend/access/gin/ginxlog.c +++ b/src/backend/access/gin/ginxlog.c @@ -626,8 +626,6 @@ gin_redo(XLogRecPtr lsn, XLogRecord *record) * posting tree is scanned in logical order during VACUUM and * no additional processing is required. */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); RestoreBkpBlocks(lsn, record, false); diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c index 4bca49324f..51050996b9 100644 --- a/src/backend/access/gist/gistxlog.c +++ b/src/backend/access/gist/gistxlog.c @@ -397,13 +397,10 @@ gist_redo(XLogRecPtr lsn, XLogRecord *record) MemoryContext oldCxt; /* - * GIST indexes do not require any conflict processing. This is - * because GIST does not remove killed tuples when it performs - * page splits in the same way b-trees do. Also VACUUMs of - * GIST indexes occur in logical not physical order. + * GIST indexes do not require any conflict processing. NB: If we ever + * implement a similar optimization we have in b-tree, and remove killed + * tuples outside VACUUM, we'll need to handle that here. */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); RestoreBkpBlocks(lsn, record, false); diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 69a37b6e78..62d37e70e0 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -4139,7 +4139,6 @@ heap_xlog_cleanup_info(XLogRecPtr lsn, XLogRecord *record) { VirtualTransactionId *backends; - RecordKnownAssignedTransactionIds(record->xl_xid); backends = GetConflictingVirtualXIDs(xlrec->latestRemovedXid, InvalidOid, true); @@ -4178,7 +4177,6 @@ heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record, bool clean_move) { VirtualTransactionId *backends; - RecordKnownAssignedTransactionIds(record->xl_xid); backends = GetConflictingVirtualXIDs(xlrec->latestRemovedXid, InvalidOid, true); @@ -4254,8 +4252,6 @@ heap_xlog_freeze(XLogRecPtr lsn, XLogRecord *record) /* * Freezing tuples does not require conflict processing */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); RestoreBkpBlocks(lsn, record, false); @@ -4856,11 +4852,9 @@ heap_redo(XLogRecPtr lsn, XLogRecord *record) uint8 info = record->xl_info & ~XLR_INFO_MASK; /* - * Heap operations don't overwrite MVCC data so no conflict - * processing is required. + * These operations don't overwrite MVCC data so no conflict + * processing is required. The ones in heap2 rmgr do. */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); RestoreBkpBlocks(lsn, record, false); diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c index 50d6ce25ca..aea48d9d54 100644 --- a/src/backend/access/nbtree/nbtxlog.c +++ b/src/backend/access/nbtree/nbtxlog.c @@ -813,7 +813,6 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record) */ if (InHotStandby) { - RecordKnownAssignedTransactionIds(record->xl_xid); if (info == XLOG_BTREE_DELETE) { xl_btree_delete *xlrec = (xl_btree_delete *) XLogRecGetData(record); diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index 521e41d10e..90de8b61b5 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -690,9 +690,6 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record) /* Backup blocks are not used in clog records */ Assert(!(record->xl_info & XLR_BKP_BLOCK_MASK)); - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - if (info == CLOG_ZEROPAGE) { int pageno; diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 055d3fe359..1cb5000c83 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -4557,14 +4557,6 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, return; } - /* - * Record any newly known assigned transactions. This looks - * strange to add xids and then immediately remove them, but - * we do other important processing here also do don't remove - * them (again). - */ - RecordKnownAssignedTransactionIds(max_xid); - /* * Mark the transaction committed in pg_clog. We use async commit * protocol during recovery to provide information on database @@ -4682,14 +4674,6 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid) if (InHotStandby) { - /* - * Record any newly known assigned transactions. This looks - * strange to add xids and then immediately remove them, but - * we do other important processing here also do don't remove - * them (again). - */ - RecordKnownAssignedTransactionIds(max_xid); - /* * We must mark clog before we update the ProcArray. */ @@ -4733,6 +4717,13 @@ xact_redo_assignment(XLogRecPtr lsn, xl_xact_assignment *xlrec) Assert(InHotStandby); + max_xid = TransactionIdLatest(xlrec->xtop, xlrec->nsubxacts, xlrec->xsub); + + /* + * Mark all the subtransactions as observed. + */ + RecordKnownAssignedTransactionIds(max_xid); + /* * Notice that we update pg_subtrans with the top-level xid, rather * than the parent xid. This is a difference between normal @@ -4751,8 +4742,6 @@ xact_redo_assignment(XLogRecPtr lsn, xl_xact_assignment *xlrec) SubTransSetParent(subxid, xlrec->xtop); } - max_xid = TransactionIdLatest(xlrec->xtop, xlrec->nsubxacts, xlrec->xsub); - /* * Remove the subxids from the array, which must occur after we have * set their parents correctly in subtrans. Record overflowed state. @@ -4784,9 +4773,6 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record) } else if (info == XLOG_XACT_PREPARE) { - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - /* the record contents are exactly the 2PC file */ RecreateTwoPhaseFile(record->xl_xid, XLogRecGetData(record), record->xl_len); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a2be37f59b..3d320bf959 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6451,6 +6451,10 @@ StartupXLOG(void) xlogctl->replayEndRecPtr = EndRecPtr; SpinLockRelease(&xlogctl->info_lck); + /* In Hot Standby mode, keep track of XIDs we've seen */ + if (InHotStandby && TransactionIdIsValid(record->xl_xid)) + RecordKnownAssignedTransactionIds(record->xl_xid); + RmgrTable[record->xl_rmid].rm_redo(EndRecPtr, record); /* Pop the error context stack */ @@ -7840,9 +7844,6 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) { Oid nextOid; - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - memcpy(&nextOid, XLogRecGetData(record), sizeof(Oid)); if (ShmemVariableCache->nextOid < nextOid) { diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c index 187f2ad9e4..11a0dc46f7 100644 --- a/src/backend/catalog/storage.c +++ b/src/backend/catalog/storage.c @@ -404,9 +404,6 @@ smgr_redo(XLogRecPtr lsn, XLogRecord *record) /* Backup blocks are not used in smgr records */ Assert(!(record->xl_info & XLR_BKP_BLOCK_MASK)); - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - if (info == XLOG_SMGR_CREATE) { xl_smgr_create *xlrec = (xl_smgr_create *) XLogRecGetData(record); diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index c64b67adad..6bf0c1dcb2 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -1962,12 +1962,6 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record) src_path = GetDatabasePath(xlrec->src_db_id, xlrec->src_tablespace_id); dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_id); - /* - * No conflict resolution is required for a create database record - */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - /* * Our theory for replaying a CREATE is to forcibly drop the target * subdirectory if present, then re-copy the source data. This may be @@ -2005,8 +1999,6 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record) { VirtualTransactionId *database_users; - RecordKnownAssignedTransactionIds(record->xl_xid); - /* * Find all users connected to this database and ask them * politely to immediately kill their sessions before processing diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index c3b5721172..64efc23eb5 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1345,9 +1345,6 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record) /* Backup blocks are not used in seq records */ Assert(!(record->xl_info & XLR_BKP_BLOCK_MASK)); - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - RestoreBkpBlocks(lsn, record, false); if (info != XLOG_SEQ_LOG) diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index f3b8ec5602..3888fd8bb6 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -1299,12 +1299,6 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record) char *location = xlrec->ts_path; char *linkloc; - /* - * No conflict resolution is required for a create tablespace record - */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - /* * Attempt to coerce target directory to safe permissions. If this * fails, it doesn't exist or has the wrong owner. @@ -1337,12 +1331,6 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record) { xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) XLogRecGetData(record); - /* - * Process recovery transaction information - */ - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - /* * If we issued a WAL record for a drop tablespace it is * because there were no files in it at all. That means that diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index eecc05df78..c9e010ed15 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -2225,12 +2225,6 @@ RecordKnownAssignedTransactionIds(TransactionId xid) (errmsg("record known xact %u latestObservedXid %u", xid, latestObservedXid))); - /* - * VACUUM records are always sent with InvalidTransactionId - */ - if (!TransactionIdIsValid(xid)) - return; - /* * Check for risk of transaction wraparound. As new xids arrive * on the standby it is eventually possible for a long lived query diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 99974fe904..0f18609ae1 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -1579,8 +1579,11 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist, } /* Reset ps display */ - set_ps_display(waitactivitymsg, false); - pgstat_report_waiting(false); + if (logged) + { + set_ps_display(waitactivitymsg, false); + pgstat_report_waiting(false); + } } /* @@ -1831,9 +1834,6 @@ relation_redo(XLogRecPtr lsn, XLogRecord *record) { uint8 info = record->xl_info & ~XLR_INFO_MASK; - if (InHotStandby) - RecordKnownAssignedTransactionIds(record->xl_xid); - if (info == XLOG_RELATION_INVAL) { xl_rel_inval *xlrec = (xl_rel_inval *) XLogRecGetData(record); -- 2.39.5