Skip to content

Commit

Permalink
merge: #11853
Browse files Browse the repository at this point in the history
11853: [Backport stable/8.1] Add warning for even replication factor r=Zelldon a=backport-action

# Description
Backport of #11831 to `stable/8.1`.

relates to 

Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
  • Loading branch information
zeebe-bors-camunda[bot] and Zelldon committed Feb 28, 2023
2 parents c200682 + 2e1d2b3 commit c4a0fbc
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public final class SystemContext {
"Node id %s needs to be non negative and smaller then cluster size %s.";
private static final String REPLICATION_FACTOR_ERROR_MSG =
"Replication factor %s needs to be larger then zero and not larger then cluster size %s.";
private static final String REPLICATION_FACTOR_WARN_MSG =
"Expected to have odd replication factor, but was even ({}). Even replication factor has no benefit over "
+ "the previous odd value and is weaker than next odd. Quorum is calculated as:"
+ " quorum = floor(replication factor / 2) + 1. In this current case the quorum will be"
+ " quorum = {}. If you want to ensure high fault-tolerance and availability,"
+ " make sure to use an odd replication factor.";
private static final String SNAPSHOT_PERIOD_ERROR_MSG =
"Snapshot period %s needs to be larger then or equals to one minute.";
private static final String MAX_BATCH_SIZE_ERROR_MSG =
Expand Down Expand Up @@ -102,6 +108,10 @@ private static void validateClusterConfig(final ClusterCfg cluster) {
String.format(REPLICATION_FACTOR_ERROR_MSG, replicationFactor, clusterSize));
}

if (replicationFactor % 2 == 0) {
LOG.warn(REPLICATION_FACTOR_WARN_MSG, replicationFactor, (replicationFactor / 2) + 1);
}

final var heartbeatInterval = cluster.getHeartbeatInterval();
final var electionTimeout = cluster.getElectionTimeout();
if (heartbeatInterval.toMillis() < 1) {
Expand Down

0 comments on commit c4a0fbc

Please sign in to comment.