aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2010-01-14 11:08:02 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2010-01-14 11:08:02 +0000
commite99767bc28d8ef9ea627cd63336b2b74087c0128 (patch)
tree29cae5f633b1ede8d959daec86aa2bb40170326d /src/backend/access
parent0fba3bef558036952f59846a7e7b48e1f5b9e479 (diff)
downloadpostgresql-e99767bc28d8ef9ea627cd63336b2b74087c0128.tar.gz
postgresql-e99767bc28d8ef9ea627cd63336b2b74087c0128.zip
First part of refactoring of code for ResolveRecoveryConflict. Purposes
of this are to centralise the conflict code to allow further change, as well as to allow passing through the full reason for the conflict through to the conflicting backends. Backend state alters how we can handle different types of conflict so this is now required. As originally suggested by Heikki, no longer optional.
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/heapam.c44
-rw-r--r--src/backend/access/nbtree/nbtxlog.c32
2 files changed, 15 insertions, 61 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index de061279a14..5cd4f005c65 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.281 2010/01/10 04:26:36 rhaas Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.282 2010/01/14 11:08:00 sriggs Exp $
*
*
* INTERFACE ROUTINES
@@ -4139,16 +4139,7 @@ heap_xlog_cleanup_info(XLogRecPtr lsn, XLogRecord *record)
xl_heap_cleanup_info *xlrec = (xl_heap_cleanup_info *) XLogRecGetData(record);
if (InHotStandby)
- {
- VirtualTransactionId *backends;
-
- backends = GetConflictingVirtualXIDs(xlrec->latestRemovedXid,
- InvalidOid,
- true);
- ResolveRecoveryConflictWithVirtualXIDs(backends,
- "VACUUM index cleanup",
- CONFLICT_MODE_ERROR);
- }
+ ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid);
/*
* Actual operation is a no-op. Record type exists to provide a means
@@ -4180,16 +4171,7 @@ heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record, bool clean_move)
* no queries running for which the removed tuples are still visible.
*/
if (InHotStandby)
- {
- VirtualTransactionId *backends;
-
- backends = GetConflictingVirtualXIDs(xlrec->latestRemovedXid,
- InvalidOid,
- true);
- ResolveRecoveryConflictWithVirtualXIDs(backends,
- "VACUUM heap cleanup",
- CONFLICT_MODE_ERROR);
- }
+ ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid);
RestoreBkpBlocks(lsn, record, true);
@@ -4259,25 +4241,7 @@ heap_xlog_freeze(XLogRecPtr lsn, XLogRecord *record)
* consider the frozen xids as running.
*/
if (InHotStandby)
- {
- VirtualTransactionId *backends;
-
- /*
- * XXX: Using cutoff_xid is overly conservative. Even if cutoff_xid
- * is recent enough to conflict with a backend, the actual values
- * being frozen might not be. With a typical vacuum_freeze_min_age
- * setting in the ballpark of millions of transactions, it won't make
- * a difference, but it might if you run a manual VACUUM FREEZE.
- * Typically the cutoff is much earlier than any recently deceased
- * tuple versions removed by this vacuum, so don't worry too much.
- */
- backends = GetConflictingVirtualXIDs(cutoff_xid,
- InvalidOid,
- true);
- ResolveRecoveryConflictWithVirtualXIDs(backends,
- "VACUUM heap freeze",
- CONFLICT_MODE_ERROR);
- }
+ ResolveRecoveryConflictWithSnapshot(cutoff_xid);
RestoreBkpBlocks(lsn, record, false);
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index 55f05bdc2c9..9e2ebd9a9f5 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.57 2010/01/02 16:57:35 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.58 2010/01/14 11:08:00 sriggs Exp $
*
*-------------------------------------------------------------------------
*/
@@ -822,28 +822,18 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record)
* just once when that arrives. After that any we know that no conflicts
* exist from individual btree vacuum records on that index.
*/
- if (InHotStandby)
+ if (InHotStandby && info == XLOG_BTREE_DELETE)
{
- if (info == XLOG_BTREE_DELETE)
- {
- xl_btree_delete *xlrec = (xl_btree_delete *) XLogRecGetData(record);
- VirtualTransactionId *backends;
-
- /*
- * XXX Currently we put everybody on death row, because
- * currently _bt_delitems() supplies InvalidTransactionId.
- * This can be fairly painful, so providing a better value
- * here is worth some thought and possibly some effort to
- * improve.
- */
- backends = GetConflictingVirtualXIDs(xlrec->latestRemovedXid,
- InvalidOid,
- true);
+ xl_btree_delete *xlrec = (xl_btree_delete *) XLogRecGetData(record);
- ResolveRecoveryConflictWithVirtualXIDs(backends,
- "b-tree delete",
- CONFLICT_MODE_ERROR);
- }
+ /*
+ * XXX Currently we put everybody on death row, because
+ * currently _bt_delitems() supplies InvalidTransactionId.
+ * This can be fairly painful, so providing a better value
+ * here is worth some thought and possibly some effort to
+ * improve.
+ */
+ ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid);
}
/*