Skip to content

Commit

Permalink
[JGRP-1282] - Race condition in FLUSH when master leaves cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Blagojevic committed Feb 8, 2011
1 parent 9a6e5f9 commit 8e5eafa
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/org/jgroups/protocols/pbcast/FLUSH.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,20 @@ private void resetForNextFlush() {
private void onSuspend(final List<Address> members) {
Message msg = null;
Collection<Address> participantsInFlush = null;
synchronized (sharedLock) {
// start FLUSH only on group members that we need to flush
participantsInFlush = members;
participantsInFlush.retainAll(currentView.getMembers());

msg = new Message(null, localAddress, null);
msg.putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId(),
participantsInFlush));
}
synchronized (sharedLock) {
flushCoordinator = localAddress;

// start FLUSH only on group members that we need to flush
participantsInFlush = members;
participantsInFlush.retainAll(currentView.getMembers());
flushMembers.clear();
flushMembers.addAll(participantsInFlush);
flushMembers.removeAll(suspected);

msg = new Message(null, localAddress, null);
msg.putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId(),
participantsInFlush));
}
if (participantsInFlush.isEmpty()) {
flush_promise.setResult(Boolean.TRUE);
} else {
Expand Down Expand Up @@ -704,14 +709,18 @@ private void onStartFlush(Address flushStarter, FlushHeader fh) {
numberOfFlushes += 1;
}
boolean proceed = false;
boolean amIFlushInitiator = false;
synchronized (sharedLock) {
flushCoordinator = flushStarter;
flushMembers.clear();
if (fh.flushParticipants != null) {
flushMembers.addAll(fh.flushParticipants);
amIFlushInitiator = flushStarter.equals(localAddress);
if(!amIFlushInitiator){
flushCoordinator = flushStarter;
flushMembers.clear();
if (fh.flushParticipants != null) {
flushMembers.addAll(fh.flushParticipants);
}
flushMembers.removeAll(suspected);
}
proceed = flushMembers.contains(localAddress);
flushMembers.removeAll(suspected);
}

if (proceed) {
Expand Down

0 comments on commit 8e5eafa

Please sign in to comment.