You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/15 08:44:10 UTC

[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #6994: Optimize ml wal limitation.

xingtanzjr commented on code in PR #6994:
URL: https://github.com/apache/iotdb/pull/6994#discussion_r945532910


##########
consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderServerImpl.java:
##########
@@ -108,49 +115,59 @@ public void stop() {
    * records the index of the log and writes locally, and then asynchronous replication is performed
    */
   public TSStatus write(IConsensusRequest request) {
-    synchronized (stateMachine) {
-      if (needToThrottleDown()) {
-        logger.info(
-            "[Throttle Down] index:{}, safeIndex:{}",
-            getIndex(),
-            getCurrentSafelyDeletedSearchIndex());
-        try {
-          stateMachine.wait(config.getReplication().getThrottleTimeOutMs());
-        } catch (InterruptedException e) {
-          logger.error("Failed to throttle down because ", e);
-          Thread.currentThread().interrupt();
+    stateMachineLock.lock();
+    try {
+      synchronized (stateMachine) {

Review Comment:
   We can remove this `synchronized` here because we already lock the `stateMachineLock`. On the other hand, when current thread trigger the `await` of condition, it still hold the `stateMachine`'s object lock, which may lead unexpected behaviors. 



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