Description of problem: If a cluster need to elect the master node it might happen that the ElectionPolicy is called multiple times by different threads. 13:40:13,832 INFO [org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.CustomElectionPolicy] (notification-thread-0) CustomElectionPolicy.Elect(). Candidates Size: 1 13:40:13,865 INFO [org.jboss.as.quickstarts.cluster.hasingleton.service.ejb.CustomElectionPolicy] (AsynchViewChangeHandler Thread) CustomElectionPolicy.Elect(). Candidates Size: 2 This might happen if one server was shutdown or after split/heal the cluster. It might happen that the singleton was not correct deactivated on one node and keep running twice.
From the analysis it will be a race between JGroups view change event and Infinispan cacheModifiedEvent.
https://github.com/jbossas/jboss-eap/pull/1536 https://github.com/jbossas/jboss-eap/pull/1537
Verified with EAP 6.4.0.DR8.