ctdb-recoverd: Clarify recovery master validation logic
authorMartin Schwenke <martin@meltin.net>
Wed, 21 Oct 2015 05:19:00 +0000 (16:19 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 16 Nov 2015 07:42:11 +0000 (08:42 +0100)
commit6f8837528f43519a98d82aa85424c1e145dc98ee
treeb77b4dfb13e4e40aacc01f7c48e8e86a69a1e5b5
parent74fa62c685069425e6e15783a0eb290e0778ce65
ctdb-recoverd: Clarify recovery master validation logic

There can be no holes in the nodemap.  Even if a node has been deleted
it will take a slot in the nodemap.  The only exception is that the
nodemap shrinks if nodes are deleted from the end.  That should never
include the master because a node should be shutdown before being
deleted, and an election should already have take place.

To avoid walking off the end of the nodemap nodes array just confirm
that the master node's PNN is a valid index into the array.  No need
to walk through the nodemap.

After this, in this section of the code j is now invalid.  So use the
master's PNN to index into the nodemap.  This is safe.

In the process, clean up some log messages to avoid saying "Force
reelection".  It's just an "election".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c