jt2594838 commented on code in PR #18841:
URL: https://github.com/apache/iotdb/pull/18841#discussion_r4268749569


##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java:
##########
@@ -1583,7 +1583,13 @@ private TSStatus 
cacheAndInsertLatestNode(DeserializedBatchIndexedConsensusReque
         for (int i = 0; i < insertNodes.size(); i++) {
           IConsensusRequest insertNode = insertNodes.get(i);
           insertNode.markAsGeneratedByRemoteConsensusLeader();
-          TSStatus status = stateMachine.write(insertNode);
+          // The replica may become read-only while this batch waits for its 
turn. Recheck before
+          // applying each request so shutdown cannot acknowledge writes after 
the final flush.
+          TSStatus status =
+              isReadOnly()
+                  ? RpcUtils.getStatus(
+                      TSStatusCode.SYSTEM_READ_ONLY, 
ConsensusMessages.SYNC_LOG_SYSTEM_READ_ONLY)
+                  : stateMachine.write(insertNode);

Review Comment:
   The system may change into read-only right inside `stateMachine.write`.
   Is this check meaningful?



-- 
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