ClusterLabs/pacemaker — pull request #517 by davidvossel (2014-05-21 19:22:39+00:00)
Title: Fix: membership: Avoid duplicate peer entries in the peer cache

There's a condition that exists that makes it possible for two identical peer entries to make it into the cluster membership peer cache.

you'll see this in the logs

WARNING: Node rhel7-auto1 and rhel7-auto1 share the same cluster nodeid: 1

This occurs If crm_get_peer is called in this order with these parameters.

1. crm_get_peer with uname and no id
this creates a peer entry with the uname

2. crm_get_peer with id only
This creates a new peer entry with the id, the uname is later looked up and set after the entry is stored.

At this point, we have two peer entries with the same uname, one with an id and one without. To avoid this, we now search the peer cache using the uname we find doing the id to uname lookup when only an id is provided.

This is difficult to hit. A lot of things have to happen in the right order, and even after those things happen this might not cause a warning message if the hash table doesn't order the duplicate entries in a certain way.

so. to make this simple.

if crm_get_peer is only passed an ID, and there's no peer in the cache for that ID , we do the corosync ID to uname lookup and then check the cache for the uname too before going off and creating a new node entry.