This is an automated email from the ASF dual-hosted git repository. adoroszlai pushed a commit to branch release-3.2.2 in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 47bae042a61638d5a5eb65dc658f1538c0afa42c Author: Doroszlai, Attila <[email protected]> AuthorDate: Fri Mar 6 08:26:18 2026 +0100 Revert "RATIS-2382. Support skip leadership check during ReadIndex (#1334)" This reverts commit bd06cf79315a065c611986ea0fe47c5b71ea3c9b. --- ratis-docs/src/site/markdown/configurations.md | 21 --------------------- .../apache/ratis/server/RaftServerConfigKeys.java | 11 ----------- .../apache/ratis/server/impl/LeaderStateImpl.java | 6 +----- 3 files changed, 1 insertion(+), 37 deletions(-) diff --git a/ratis-docs/src/site/markdown/configurations.md b/ratis-docs/src/site/markdown/configurations.md index 67e988348..3d2c9318c 100644 --- a/ratis-docs/src/site/markdown/configurations.md +++ b/ratis-docs/src/site/markdown/configurations.md @@ -226,27 +226,6 @@ if it fails to receive any RPC responses from this peer within this specified ti | **Type** | boolean | | **Default** | false | -| **Property** | `raft.server.read.leader.heartbeat-check.enabled` | -|:----------------|:--------------------------------------------------| -| **Description** | whether to check heartbeat for read index. | -| **Type** | boolean | -| **Default** | true | - -Note that the original read index algorithm requires heartbeat check -in order to guarantee linearizable read. -By setting this property to false, -it reduces the RTT by eliminating the heartbeat check. -However, it might cause the reads not to be linearizable in a split-brain case. -Without the heartbeat check, a leader might not be the latest leader -and, as a result, it might serve stale reads. -When there is a split brain, there might be a small period of time -that the (old) leader has lost majority heartbeats but have not yet detected it. -As the same time, a new leader is elected by a majority of peers. -Then, the old leader might serve stale data -since it does not have the transactions committed by the new leaders. -Since such split-brain case is supposed to be rare, -it might be an acceptable tradeoff for applications that -seek to improve the linearizable read performance. ### Write - Configurations related to write requests. diff --git a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java index ef16f67f6..efb3c6796 100644 --- a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java +++ b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java @@ -249,17 +249,6 @@ public interface RaftServerConfigKeys { setDouble(properties::setDouble, LEADER_LEASE_TIMEOUT_RATIO_KEY, ratio); } - String LEADER_HEARTBEAT_CHECK_ENABLED_KEY = PREFIX + ".leader.heartbeat-check.enabled"; - boolean LEADER_HEARTBEAT_CHECK_ENABLED_DEFAULT = true; - static boolean leaderHeartbeatCheckEnabled(RaftProperties properties) { - return getBoolean(properties::getBoolean, LEADER_HEARTBEAT_CHECK_ENABLED_KEY, - LEADER_HEARTBEAT_CHECK_ENABLED_DEFAULT, getDefaultLog()); - } - - static void setLeaderHeartbeatCheckEnabled(RaftProperties properties, boolean enabled) { - setBoolean(properties::setBoolean, LEADER_HEARTBEAT_CHECK_ENABLED_KEY, enabled); - } - interface ReadAfterWriteConsistent { String PREFIX = Read.PREFIX + ".read-after-write-consistent"; diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java index ef0bb6b70..90d0b76df 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java @@ -354,7 +354,6 @@ class LeaderStateImpl implements LeaderState { private final ReadIndexHeartbeats readIndexHeartbeats; private final boolean readIndexAppliedIndexEnabled; - private final boolean leaderHeartbeatCheckEnabled; private final LeaderLease lease; LeaderStateImpl(RaftServerImpl server) { @@ -393,8 +392,6 @@ class LeaderStateImpl implements LeaderState { } this.readIndexAppliedIndexEnabled = RaftServerConfigKeys.Read.ReadIndex .appliedIndexEnabled(properties); - this.leaderHeartbeatCheckEnabled = RaftServerConfigKeys.Read - .leaderHeartbeatCheckEnabled(properties); final RaftConfigurationImpl conf = state.getRaftConf(); Collection<RaftPeer> others = conf.getOtherPeers(server.getId()); @@ -1169,8 +1166,7 @@ class LeaderStateImpl implements LeaderState { } // if lease is enabled, check lease first - // if we allow leader to skip the leadership check heartbeat, we can return immediately - if (!leaderHeartbeatCheckEnabled || hasLease()) { + if (hasLease()) { return CompletableFuture.completedFuture(readIndex); }
