HAWQ-853. Master standby should avoid incomplete split operation

    Master standby performs replay of xlog records within a range of
    checkpoints similar to crash recovery. During this is it may replay
    incomplete multi-step operation at the end of the range. This generates
    xlog. But Master standby should not generate xlog as it does not have
    WAL subsystem active.

    This fix avoids completing such operation e.g. Btree split if the
    system is in standby mode.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/74401eb0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/74401eb0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/74401eb0

Branch: refs/heads/HAWQ-537
Commit: 74401eb070979692771b882ea51ed7e05af29c5f
Parents: 0f6ac20
Author: Wen Lin <w...@pivotal.io>
Authored: Thu Jun 23 09:38:24 2016 +0800
Committer: Wen Lin <w...@pivotal.io>
Committed: Thu Jun 23 09:38:24 2016 +0800

----------------------------------------------------------------------
 src/backend/access/nbtree/nbtxlog.c | 10 ++++++++++
 src/backend/access/transam/xlog.c   |  6 ++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/74401eb0/src/backend/access/nbtree/nbtxlog.c
----------------------------------------------------------------------
diff --git a/src/backend/access/nbtree/nbtxlog.c 
b/src/backend/access/nbtree/nbtxlog.c
index f0b6507..98dd5ec 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -52,6 +52,11 @@ static void
 log_incomplete_split(RelFileNode node, BlockNumber leftblk,
                                         BlockNumber rightblk, bool is_root)
 {
+       if (! CanEmitXLogRecords)       /*  only log incomplete split if could 
emit xlog */
+       {
+               return;
+       }
+
        bt_incomplete_action *action = palloc(sizeof(bt_incomplete_action));
 
        action->node = node;
@@ -88,6 +93,11 @@ forget_matching_split(RelFileNode node, BlockNumber 
downlink, bool is_root)
 static void
 log_incomplete_deletion(RelFileNode node, BlockNumber delblk)
 {
+       if (! CanEmitXLogRecords)       /*  only log incomplete deletion if 
could emit xlog */
+       {
+               return;
+       }
+
        bt_incomplete_action *action = palloc(sizeof(bt_incomplete_action));
 
        action->node = node;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/74401eb0/src/backend/access/transam/xlog.c
----------------------------------------------------------------------
diff --git a/src/backend/access/transam/xlog.c 
b/src/backend/access/transam/xlog.c
index 7a50c17..a0b3c82 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7404,6 +7404,12 @@ XLogStandbyRecoverRange(XLogRecPtr *redoCheckpointLoc, 
CheckPoint *redoCheckPoin
        ShmemVariableCache->oidCount = 0;
        MultiXactSetNextMXact(redoCheckPoint->nextMulti, 
redoCheckPoint->nextMultiOffset);
 
+       /*
+        * Should not emit XLog during standby redo. This method is called only
+        * by standby walredo process.
+        */
+       CanEmitXLogRecords = false;
+
        /* Start up the recovery environment */
        XLogInitRelationCache();
 

Reply via email to