You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "SzyWilliam (via GitHub)" <gi...@apache.org> on 2023/11/18 06:17:19 UTC

[PR] [IOTDB-6251] Make read in SchemaRegion linearizable by default [iotdb]

SzyWilliam opened a new pull request, #11571:
URL: https://github.com/apache/iotdb/pull/11571

   See https://issues.apache.org/jira/browse/IOTDB-6251
   See experiments in https://apache-iotdb.feishu.cn/docx/NJ7vdd9Kfo3nx2xwalZcqBeunr8


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [IOTDB-6251] Make read in SchemaRegion linearizable by default [iotdb]

Posted by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org>.
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [IOTDB-6251] Make read in SchemaRegion linearizable by default [iotdb]

Posted by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org>.
OneSizeFitsQuorum merged PR #11571:
URL: https://github.com/apache/iotdb/pull/11571


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [IOTDB-6251] Make read in SchemaRegion linearizable by default [iotdb]

Posted by "SzyWilliam (via GitHub)" <gi...@apache.org>.
SzyWilliam commented on code in PR #11571:
URL: https://github.com/apache/iotdb/pull/11571#discussion_r1398618183


##########
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:
   Done



##########
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:
   Done



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org