Skip to content

Commit

Permalink
limit bootstrapping to min of 4. fix RingIterator logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Jun 11, 2024
1 parent a2c3a9f commit 33cc83f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import org.slf4j.LoggerFactory;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -42,8 +40,8 @@
import static com.salesforce.apollo.ethereal.memberships.comm.GossiperClient.getCreate;

/**
* Handles the gossip propigation of proposals, commits and preVotes from this node, as well as the notification of the
* adder of such from other nodes.
* Handles the gossip propagation of proposals, the commits and preVotes from this node, and the notification of the
* Adder of such events from other nodes.
*
* @author hal.hildebrand
*/
Expand All @@ -59,7 +57,6 @@ public class ChRbcGossip {
private final SliceIterator<Gossiper> ring;
private final AtomicBoolean started = new AtomicBoolean();
private final Terminal terminal = new Terminal();
private final List<Member> membership;
private volatile ScheduledFuture<?> scheduled;

public ChRbcGossip(Digest id, SigningMember member, Collection<Member> membership, Processor processor,
Expand All @@ -68,12 +65,10 @@ public ChRbcGossip(Digest id, SigningMember member, Collection<Member> membershi
this.member = member;
this.metrics = m;
this.id = id;
this.membership = new ArrayList<>(membership);
comm = communications.create(member, id, terminal, getClass().getCanonicalName(),
r -> new GossiperServer(communications.getClientIdentityProvider(), metrics, r),
getCreate(metrics), Gossiper.getLocalLoopback(member));
ring = new SliceIterator<Gossiper>("ChRbcGossip[%s on: %s]".formatted(id, member.getId()), member, membership,
comm);
ring = new SliceIterator<>("ChRbcGossip[%s on: %s]".formatted(id, member.getId()), member, membership, comm);
}

/**
Expand Down Expand Up @@ -150,7 +145,7 @@ private Update gossipRound(Gossiper link) {
if (!started.get()) {
return null;
}
log.trace("gossiping[{}] with {} on {}", id, link.getMember(), member);
log.trace("gossiping[{}] with {} on {}", id, link.getMember(), member.getId());
try {
return link.gossip(processor.gossip(id));
} catch (StatusRuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class View {
private static final String FINALIZE_VIEW_CHANGE = "FINALIZE VIEW CHANGE";
private static final Logger log = LoggerFactory.getLogger(View.class);
private static final String SCHEDULED_VIEW_CHANGE = "Scheduled View Change";

final CommonCommunications<Fireflies, Service> comm;
final AtomicBoolean started = new AtomicBoolean();
private final CommonCommunications<Entrance, Service> approaches;
Expand Down Expand Up @@ -343,8 +343,8 @@ void finalizeViewChange() {
return;
}
viewChange(() -> {
final var superMajority =
context.size() == 1 ? 1 : context.getRingCount() - ((context.getRingCount() - 1) / 4);
var rings = context.getRingCount();
final var superMajority = context.size() == 1 ? 1 : rings - ((rings - 1) / 4);
if (observations.size() < superMajority) {
log.trace("Do not have superMajority: {} required: {} observers: {} for: {} on: {}",
observations.size(), superMajority, viewManagement.observersList(), currentView(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ boolean joined() {
* start a view change if there are any offline members or joining members
*/
void maybeViewChange() {
if (context.size() == 1 && joins.size() < 3) {
log.info("Do not have minimum cluster size: {} required: {} for: {} on: {}", joins.size() + context.size(),
4, currentView(), node.getId());
view.scheduleViewChange();
return;
}
if ((context.offlineCount() > 0 || !joins.isEmpty())) {
if (isObserver()) {
log.trace("Initiating view change: {} (non observer) joins: {} leaves: {} on: {}", currentView(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,17 @@ private void proceed(Digest key, final boolean allow, Runnable onMajority, Runna
if (!finalIteration) {
log.trace(
"Determining: {} continuation of: {} for digest: {} tally: {} majority: {} final itr: {} allow: {} on: {}",
current, key, context.getId(), tally.get(), context.majority(), finalIteration, allow, member.getId());
current, key, context.getId(), tally.get(), context.toleranceLevel() + 1, finalIteration, allow,
member.getId());
}
if (finalIteration && allow) {
log.trace("Completing iteration: {} of: {} for digest: {} tally: {} on: {}", iteration(), key,
context.getId(), tally.get(), member.getId());
if (failedMajority != null && !majorityFailed) {
if (tally.get() < context.majority()) {
if (tally.get() < context.toleranceLevel() + 1) {
majorityFailed = true;
log.debug("Failed to obtain majority of: {} for digest: {} tally: {} required: {} on: {}", key,
context.getId(), tally.get(), context.majority(), member.getId());
context.getId(), tally.get(), context.toleranceLevel() + 1, member.getId());
failedMajority.run();
}
}
Expand Down

0 comments on commit 33cc83f

Please sign in to comment.