File pacemaker-cib-re-sync-handling.patch of Package pacemaker.14737

commit 3a94d53c8dee82033a8087739b3ee3429cf2b18d
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Tue Jan 24 18:24:07 2017 -0600

    Low: cib: improve re-sync handling
    
    Sync requests should reset (rather than increment) the ignored diff counter;
    if we're repeatedly requesting syncs, we don't want that to count towards
    ignored diffs, otherwise we just request more syncs.
    
    Also, a3afaeff added sync requests when an update fails in legacy mode, to get
    the full CIB from the master. The master shouldn't make these requests.

Index: pacemaker/cib/messages.c
===================================================================
--- pacemaker.orig/cib/messages.c
+++ pacemaker/cib/messages.c
@@ -40,6 +40,7 @@
 #include <cibmessages.h>
 #include <callbacks.h>
 
+/* Maximum number of diffs to ignore while waiting for a resync */
 #define MAX_DIFF_RETRY 5
 
 #ifdef CIBPIPE
@@ -176,14 +177,18 @@ cib_process_readwrite(const char *op, in
 #endif
 }
 
-int sync_in_progress = 0;
+/* Set to 1 when a sync is requested, incremented when a diff is ignored,
+ * reset to 0 when a sync is received
+ */
+static int sync_in_progress = 0;
+
 void
 send_sync_request(const char *host)
 {
     xmlNode *sync_me = create_xml_node(NULL, "sync-me");
 
-    crm_info("Requesting re-sync from peer");
-    sync_in_progress++;
+    crm_info("Requesting re-sync from %s", (host? host : "all peers"));
+    sync_in_progress = 1;
 
     crm_xml_add(sync_me, F_TYPE, "cib");
     crm_xml_add(sync_me, F_CIB_OPERATION, CIB_OP_SYNC_ONE);
@@ -336,19 +341,15 @@ cib_server_process_diff(const char *op,
 {
     int rc = pcmk_ok;
 
-    if (cib_is_master) {
-        /* the master is never waiting for a resync */
-        sync_in_progress = 0;
-    }
-
     if (sync_in_progress > MAX_DIFF_RETRY) {
-        /* request another full-sync,
-         * the last request may have been lost
+        /* Don't ignore diffs forever; the last request may have been lost.
+         * If the diff fails, we'll ask for another full resync.
          */
         sync_in_progress = 0;
     }
 
-    if (sync_in_progress) {
+    /* The master should never ignore a diff */
+    if (sync_in_progress && !cib_is_master) {
         int diff_add_updates = 0;
         int diff_add_epoch = 0;
         int diff_add_admin_epoch = 0;
@@ -382,7 +383,7 @@ cib_server_process_diff(const char *op,
             crm_warn("Not requesting full refresh in R/W mode");
         }
 
-    } else if(rc != pcmk_ok && cib_legacy_mode()) {
+    } else if ((rc != pcmk_ok) && !cib_is_master && cib_legacy_mode()) {
         crm_warn("Requesting full CIB refresh because update failed: %s"
                  CRM_XS " rc=%d", pcmk_strerror(rc), rc);
         xml_log_patchset(LOG_INFO, __FUNCTION__, input);
openSUSE Build Service is sponsored by