diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2010-01-29 18:39:05 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2010-01-29 18:39:05 +0000 |
commit | 6d2bc0a6cf5c8d9a3241a0d7afaf5ca8bf1f11ec (patch) | |
tree | a99f7e3490d28b3546b909796ad76c8b6322cf72 /src/backend/access/nbtree/nbtpage.c | |
parent | d0cfc018233b4cdcab28d460ee0e14dbf87ac4ce (diff) | |
download | postgresql-6d2bc0a6cf5c8d9a3241a0d7afaf5ca8bf1f11ec.tar.gz |
Augment WAL records for btree delete with GetOldestXmin() to reduce
false positives during Hot Standby conflict processing. Simple
patch to enhance conflict processing, following previous discussions.
Controlled by parameter minimize_standby_conflicts = on | off, with
default off allows measurement of performance impact to see whether
it should be set on all the time.
Diffstat (limited to 'src/backend/access/nbtree/nbtpage.c')
-rw-r--r-- | src/backend/access/nbtree/nbtpage.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 7cd76e10cf..5fa4724602 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.115 2010/01/02 16:57:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.116 2010/01/29 18:39:05 sriggs Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -29,6 +29,7 @@ #include "storage/freespace.h" #include "storage/indexfsm.h" #include "storage/lmgr.h" +#include "storage/procarray.h" #include "utils/inval.h" #include "utils/snapmgr.h" @@ -671,9 +672,18 @@ _bt_delitems(Relation rel, Buffer buf, { Page page = BufferGetPage(buf); BTPageOpaque opaque; + TransactionId latestRemovedXid = InvalidTransactionId; Assert(isVacuum || lastBlockVacuumed == 0); + /* + * If allowed, calculate an accurate latestRemovedXid, otherwise + * pass InvalidTransactionId which can cause false positive + * conflicts to be assessed when we replay this WAL record. + */ + if (!isVacuum && XLogStandbyInfoActive() && MinimizeStandbyConflicts) + latestRemovedXid = GetOldestXmin(false, true); + /* No ereport(ERROR) until changes are logged */ START_CRIT_SECTION(); @@ -721,13 +731,7 @@ _bt_delitems(Relation rel, Buffer buf, xlrec_delete.node = rel->rd_node; xlrec_delete.block = BufferGetBlockNumber(buf); - /* - * XXX: We would like to set an accurate latestRemovedXid, but - * there is no easy way of obtaining a useful value. So we punt - * and store InvalidTransactionId, which forces the standby to - * wait for/cancel all currently running transactions. - */ - xlrec_delete.latestRemovedXid = InvalidTransactionId; + xlrec_delete.latestRemovedXid = latestRemovedXid; rdata[0].data = (char *) &xlrec_delete; rdata[0].len = SizeOfBtreeDelete; } |