OneSizeFitsQuorum commented on code in PR #11571:
URL: https://github.com/apache/iotdb/pull/11571#discussion_r1398576513


##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java:
##########
@@ -327,21 +331,25 @@ public DataSet read(ConsensusGroupId groupId, 
IConsensusRequest request)
       throw new ConsensusGroupNotExistException(groupId);
     }
 
+    // perform linearizable read under following two conditions:
+    // 1. Read.Option is linearizable
+    // 2. First probing read when Read.Option is default
     final boolean isLinearizableRead =
-        !canServeStaleRead.computeIfAbsent(groupId, id -> new 
AtomicBoolean(false)).get();
+        readOption == RatisConfig.Read.Option.LINEARIZABLE
+            || !canServeStaleRead.computeIfAbsent(groupId, id -> new 
AtomicBoolean(false)).get();
 
     RaftClientReply reply;
     try {
       reply = doRead(raftGroupId, request, isLinearizableRead);
       // allow stale read if current linearizable read returns successfully
-      if (isLinearizableRead) {
+      if (readOption == RatisConfig.Read.Option.DEFAULT && isLinearizableRead) 
{

Review Comment:
   Optional.ofNullable.IfPresent ?



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.java:
##########
@@ -307,11 +307,7 @@ public static void initRatisConfig(RaftProperties 
properties, RatisConfig config
     RaftServerConfigKeys.Rpc.setFirstElectionTimeoutMax(
         properties, config.getRpc().getFirstElectionTimeoutMax());
 
-    RaftServerConfigKeys.Read.Option option =
-        config.getRead().getReadOption() == RatisConfig.Read.Option.DEFAULT
-            ? RaftServerConfigKeys.Read.Option.DEFAULT
-            : RaftServerConfigKeys.Read.Option.LINEARIZABLE;
-    RaftServerConfigKeys.Read.setOption(properties, option);
+    RaftServerConfigKeys.Read.setOption(properties, 
RaftServerConfigKeys.Read.Option.LINEARIZABLE);

Review Comment:
   use value in the config?



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java:
##########
@@ -766,6 +774,14 @@ private RaftClientReply sendReconfiguration(RaftGroup 
newGroupConf)
     return reply;
   }
 
+  private void onLeaderChanged(RaftGroupMemberId groupMemberId, RaftPeerId 
leaderId) {

Review Comment:
   Optional.ofNullable.IfPresent ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to