Skip to content

Commit

Permalink
merge: #11854
Browse files Browse the repository at this point in the history
11854: [Backport 8.0]:  Add warning for even replication factor r=oleschoenburg a=Zelldon

## Description

Backports #11831 
<!-- Please explain the changes you made here. -->

Had to resolve some smaller merge conflicts, in the system context.


Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
  • Loading branch information
zeebe-bors-camunda[bot] and Zelldon committed Feb 28, 2023
2 parents 11cb1c7 + a4fb532 commit 8ac13d8
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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 @@ -96,6 +102,10 @@ private void validateConfiguration() {

final var dataCfg = brokerCfg.getData();

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

final var snapshotPeriod = dataCfg.getSnapshotPeriod();
if (snapshotPeriod.isNegative() || snapshotPeriod.minus(MINIMUM_SNAPSHOT_PERIOD).isNegative()) {
throw new IllegalArgumentException(String.format(SNAPSHOT_PERIOD_ERROR_MSG, snapshotPeriod));
Expand Down

0 comments on commit 8ac13d8

Please sign in to comment.