Skip to content

Commit 435b772

Browse files
author
Ken Gaillot
committed
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
1 parent 6ddb87f commit 435b772

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

daemons/attrd/attrd_elections.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2018 Andrew Beekhof <[email protected]>
2+
* Copyright 2013-2019 Andrew Beekhof <[email protected]>
33
*
44
* This source code is licensed under the GNU General Public License version 2
55
* or later (GPLv2+) WITHOUT ANY WARRANTY.
@@ -131,12 +131,20 @@ attrd_declare_winner()
131131
void
132132
attrd_remove_voter(const crm_node_t *peer)
133133
{
134+
election_remove(writer, peer->uname);
134135
if (peer_writer && safe_str_eq(peer->uname, peer_writer)) {
135136
free(peer_writer);
136137
peer_writer = NULL;
137138
crm_notice("Lost attribute writer %s", peer->uname);
139+
140+
/* If the writer received attribute updates during its shutdown, it will
141+
* not have written them to the CIB. Ensure we get a new writer so they
142+
* are written out. This means that every node that sees the writer
143+
* leave will start a new election, but that's better than losing
144+
* attributes.
145+
*/
146+
attrd_start_election_if_needed();
138147
}
139-
election_remove(writer, peer->uname);
140148
}
141149

142150
void

0 commit comments

Comments
 (0)