OSDN Git Service

Prevents query conflict from suspending a failover.
authorMasaoFujii <masao.fujii@gmail.com>
Thu, 9 Dec 2010 13:42:25 +0000 (22:42 +0900)
committerMasaoFujii <masao.fujii@gmail.com>
Thu, 9 Dec 2010 13:42:25 +0000 (22:42 +0900)
After the standby has been triggered, we cancel the
conflicting query and transactions immediately to
speed up a failover.

src/backend/access/transam/xlog.c
src/backend/storage/ipc/standby.c
src/include/access/xlog.h

index f22139b..239abf9 100644 (file)
@@ -9768,12 +9768,22 @@ CheckForStandbyTrigger(void)
                                (errmsg("trigger file found: %s", TriggerFile)));
                ShutdownWalRcv();
                unlink(TriggerFile);
+               standby_triggered = true;
                return true;
        }
        return false;
 }
 
 /*
+ * Is the standby triggered?
+ */
+bool
+StandbyIsTriggered(void)
+{
+       return standby_triggered;
+}
+
+/*
  * Wake up startup process to replay newly arrived WAL, or to notice that
  * failover has been requested.
  */
index 2f9fe8a..3836e1d 100644 (file)
@@ -227,7 +227,7 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
                        }
 
                        /* Is it time to kill it? */
-                       if (WaitExceedsMaxStandbyDelay())
+                       if (StandbyIsTriggered() || WaitExceedsMaxStandbyDelay())
                        {
                                pid_t           pid;
 
index fa6d84c..6dba7dc 100644 (file)
@@ -331,6 +331,7 @@ extern TimeLineID GetRecoveryTargetTLI(void);
 
 extern void HandleStartupProcInterrupts(void);
 extern void StartupProcessMain(void);
+extern bool StandbyIsTriggered(void);
 extern void WakeupRecovery(void);
 
 #endif   /* XLOG_H */