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 dffd940f75d26db200687384659f14f8520af5ed
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri Mar 6 08:26:18 2026 +0100

    Revert "RATIS-2379. Support returning applied index for ReadIndex (#1332)"
    
    This reverts commit 51f1e8e90a2e289f02f1e18470ceed11fa9c2998.
---
 ratis-docs/src/site/markdown/configurations.md     |  7 ------
 .../apache/ratis/server/RaftServerConfigKeys.java  | 15 ------------
 .../apache/ratis/server/impl/LeaderStateImpl.java  | 17 +++++---------
 .../org/apache/ratis/LinearizableReadTests.java    |  3 ---
 .../TestLinearizableLeaderLeaseReadWithGrpc.java   |  5 ----
 ...bleReadAppliedIndexLeaderLeaseReadWithGrpc.java | 27 ----------------------
 .../TestLinearizableReadAppliedIndexWithGrpc.java  | 27 ----------------------
 .../ratis/grpc/TestLinearizableReadWithGrpc.java   |  5 ----
 8 files changed, 6 insertions(+), 100 deletions(-)

diff --git a/ratis-docs/src/site/markdown/configurations.md 
b/ratis-docs/src/site/markdown/configurations.md
index 3d2c9318c..c514e540f 100644
--- a/ratis-docs/src/site/markdown/configurations.md
+++ b/ratis-docs/src/site/markdown/configurations.md
@@ -218,13 +218,6 @@ if it fails to receive any RPC responses from this peer 
within this specified ti
 | **Type**        | TimeDuration                                               
                    |
 | **Default**     | 60s                                                        
                    |
 
-### Read Index - Configurations related to ReadIndex used in linearizable read 
-
-| **Property**    | `raft.server.read.read-index.applied-index.enabled`        
           |
-|:----------------|:----------------------------------------------------------------------|
-| **Description** | whether applied index (instead of commit index) is used 
for ReadIndex |
-| **Type**        | boolean                                                    
           |
-| **Default**     | false                                                      
           |
 
 
 ### 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 efb3c6796..cddfe3a50 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
@@ -265,21 +265,6 @@ public interface RaftServerConfigKeys {
         setTimeDuration(properties::setTimeDuration, 
WRITE_INDEX_CACHE_EXPIRY_TIME_KEY, expiryTime);
       }
     }
-
-    interface ReadIndex {
-      String PREFIX = Read.PREFIX + ".read-index";
-
-      String APPLIED_INDEX_ENABLED_KEY = PREFIX + ".applied-index.enabled";
-      boolean APPLIED_INDEX_ENABLED_DEFAULT = false;
-      static boolean appliedIndexEnabled(RaftProperties properties) {
-        return getBoolean(properties::getBoolean, APPLIED_INDEX_ENABLED_KEY,
-            APPLIED_INDEX_ENABLED_DEFAULT, getDefaultLog());
-      }
-
-      static void setAppliedIndexEnabled(RaftProperties properties, boolean 
enabled) {
-        setBoolean(properties::setBoolean, APPLIED_INDEX_ENABLED_KEY, enabled);
-      }
-    }
   }
 
   interface Write {
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 90d0b76df..836b15bcd 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
@@ -353,7 +353,6 @@ class LeaderStateImpl implements LeaderState {
   private final PendingStepDown pendingStepDown;
 
   private final ReadIndexHeartbeats readIndexHeartbeats;
-  private final boolean readIndexAppliedIndexEnabled;
   private final LeaderLease lease;
 
   LeaderStateImpl(RaftServerImpl server) {
@@ -390,8 +389,6 @@ class LeaderStateImpl implements LeaderState {
     } else {
       this.followerMaxGapThreshold = (long) (followerGapRatioMax * 
maxPendingRequests);
     }
-    this.readIndexAppliedIndexEnabled = RaftServerConfigKeys.Read.ReadIndex
-        .appliedIndexEnabled(properties);
 
     final RaftConfigurationImpl conf = state.getRaftConf();
     Collection<RaftPeer> others = conf.getOtherPeers(server.getId());
@@ -1137,23 +1134,21 @@ class LeaderStateImpl implements LeaderState {
   /**
    * Obtain the current readIndex for read only requests. See Raft paper 
section 6.4.
    * 1. Leader makes sure at least one log from current term is committed.
-   * 2. Leader record last committed index or applied index (depending on 
configuration) as readIndex.
+   * 2. Leader record last committed index as readIndex.
    * 3. Leader broadcast heartbeats to followers and waits for 
acknowledgements.
    * 4. If majority respond success, returns readIndex.
    * @return current readIndex.
    */
   CompletableFuture<Long> getReadIndex(Long readAfterWriteConsistentIndex) {
-    final long index = readIndexAppliedIndexEnabled ?
-        server.getState().getLastAppliedIndex() : 
server.getRaftLog().getLastCommittedIndex();
+    final long commitIndex = server.getRaftLog().getLastCommittedIndex();
     final long readIndex;
-    if (readAfterWriteConsistentIndex != null && readAfterWriteConsistentIndex 
> index) {
+    if (readAfterWriteConsistentIndex != null && readAfterWriteConsistentIndex 
> commitIndex) {
       readIndex = readAfterWriteConsistentIndex;
     } else {
-      readIndex = index;
+      readIndex = commitIndex;
     }
-    LOG.debug("readIndex={} ({}Index={}, readAfterWriteConsistentIndex={})",
-        readIndex, readIndexAppliedIndexEnabled ? "applied" : "commit",
-        index, readAfterWriteConsistentIndex);
+    LOG.debug("readIndex={} (commitIndex={}, 
readAfterWriteConsistentIndex={})",
+        readIndex, commitIndex, readAfterWriteConsistentIndex);
 
     // if group contains only one member, fast path
     if (server.getRaftConf().isSingleton()) {
diff --git 
a/ratis-server/src/test/java/org/apache/ratis/LinearizableReadTests.java 
b/ratis-server/src/test/java/org/apache/ratis/LinearizableReadTests.java
index b15ae3067..91bd2f28d 100644
--- a/ratis-server/src/test/java/org/apache/ratis/LinearizableReadTests.java
+++ b/ratis-server/src/test/java/org/apache/ratis/LinearizableReadTests.java
@@ -60,8 +60,6 @@ public abstract class LinearizableReadTests<CLUSTER extends 
MiniRaftCluster>
 
   public abstract boolean isLeaderLeaseEnabled();
 
-  public abstract boolean readIndexAppliedIndexEnabled();
-
   public abstract void assertRaftProperties(RaftProperties properties);
 
   void runWithNewCluster(CheckedConsumer<CLUSTER, Exception> testCase) throws 
Exception {
@@ -77,7 +75,6 @@ public abstract class LinearizableReadTests<CLUSTER extends 
MiniRaftCluster>
     CounterStateMachine.setProperties(p);
     RaftServerConfigKeys.Read.setOption(p, LINEARIZABLE);
     RaftServerConfigKeys.Read.setLeaderLeaseEnabled(p, isLeaderLeaseEnabled());
-    RaftServerConfigKeys.Read.ReadIndex.setAppliedIndexEnabled(p, 
readIndexAppliedIndexEnabled());
   }
 
   @Test
diff --git 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableLeaderLeaseReadWithGrpc.java
 
b/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableLeaderLeaseReadWithGrpc.java
index d637498d7..e45d8f4ff 100644
--- 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableLeaderLeaseReadWithGrpc.java
+++ 
b/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableLeaderLeaseReadWithGrpc.java
@@ -34,11 +34,6 @@ public class TestLinearizableLeaderLeaseReadWithGrpc
     return true;
   }
 
-  @Override
-  public boolean readIndexAppliedIndexEnabled() {
-    return false;
-  }
-
   @Override
   public void assertRaftProperties(RaftProperties p) {
     assertOption(LINEARIZABLE, p);
diff --git 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadAppliedIndexLeaderLeaseReadWithGrpc.java
 
b/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadAppliedIndexLeaderLeaseReadWithGrpc.java
deleted file mode 100644
index 9bf3e307b..000000000
--- 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadAppliedIndexLeaderLeaseReadWithGrpc.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ratis.grpc;
-
-public class TestLinearizableReadAppliedIndexLeaderLeaseReadWithGrpc
-    extends TestLinearizableLeaderLeaseReadWithGrpc {
-
-  @Override
-  public boolean readIndexAppliedIndexEnabled() {
-    return true;
-  }
-}
diff --git 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadAppliedIndexWithGrpc.java
 
b/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadAppliedIndexWithGrpc.java
deleted file mode 100644
index c019aac16..000000000
--- 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadAppliedIndexWithGrpc.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ratis.grpc;
-
-public class TestLinearizableReadAppliedIndexWithGrpc
-  extends TestLinearizableReadWithGrpc {
-
-  @Override
-  public boolean readIndexAppliedIndexEnabled() {
-    return true;
-  }
-}
diff --git 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadWithGrpc.java
 
b/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadWithGrpc.java
index 3e8860dd1..a434fe000 100644
--- 
a/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadWithGrpc.java
+++ 
b/ratis-test/src/test/java/org/apache/ratis/grpc/TestLinearizableReadWithGrpc.java
@@ -34,11 +34,6 @@ public class TestLinearizableReadWithGrpc
     return false;
   }
 
-  @Override
-  public boolean readIndexAppliedIndexEnabled() {
-    return false;
-  }
-
   @Override
   public void assertRaftProperties(RaftProperties p) {
     assertOption(LINEARIZABLE, p);

Reply via email to