File rh#1535221-0001-Fix-attrd-start-new-election-if-writer-is-lost-1.1.patch of Package pacemaker.22685

From 7a4e640df204acf34dd5766f551b1a9fea37c8ac Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Thu, 3 Jan 2019 15:13:42 -0600
Subject: [PATCH] Fix: attrd: start new election if writer is lost

If a writer is shutting down when it receives an attribute update, it will not
write it to the CIB. Previously, a new election wouldn't be held until another
attribute needed to be written, which may not happen in a reasonable time (or
at all). Now, we trigger a new election when the writer leaves the cluster.

rhbz#1535221
---
 attrd/attrd_elections.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/attrd/attrd_elections.c b/attrd/attrd_elections.c
index 198423fd4..921fb956f 100644
--- a/attrd/attrd_elections.c
+++ b/attrd/attrd_elections.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013-2018 Andrew Beekhof <andrew@beekhof.net>
+ * Copyright 2013-2019 Andrew Beekhof <andrew@beekhof.net>
  *
  * This source code is licensed under the GNU General Public License version 2
  * or later (GPLv2+) WITHOUT ANY WARRANTY.
@@ -126,12 +126,20 @@ attrd_declare_winner()
 void
 attrd_remove_voter(const crm_node_t *peer)
 {
+    election_remove(writer, peer->uname);
     if (peer_writer && safe_str_eq(peer->uname, peer_writer)) {
         free(peer_writer);
         peer_writer = NULL;
         crm_notice("Lost attribute writer %s", peer->uname);
+
+        /* If the writer received attribute updates during its shutdown, it will
+         * not have written them to the CIB. Ensure we get a new writer so they
+         * are written out. This means that every node that sees the writer
+         * leave will start a new election, but that's better than losing
+         * attributes.
+         */
+        attrd_start_election_if_needed();
     }
-    election_remove(writer, peer->uname);
 }
 
 void
-- 
2.34.1

openSUSE Build Service is sponsored by