This is an automated email from the ASF dual-hosted git repository.

xingtanzjr pushed a commit to branch ml_0729_test_exp1_no_write
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/ml_0729_test_exp1_no_write by 
this push:
     new 238c3598c7 fix the issue for deadlock
238c3598c7 is described below

commit 238c3598c78fdf9fb90636d62bf788393ab34fb8
Author: Jinrui.Zhang <[email protected]>
AuthorDate: Fri Aug 5 19:55:23 2022 +0800

    fix the issue for deadlock
---
 .../iotdb/consensus/multileader/logdispatcher/LogDispatcher.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
 
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
index ef72907d35..8bd70ae18c 100644
--- 
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
+++ 
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
@@ -118,9 +118,12 @@ public class LogDispatcher {
               thread.getPendingRequest().size());
           long putToQueueStartTime = System.nanoTime();
           try {
-            thread
+            while (!thread
                 .getPendingRequest()
-                .put(new IndexedConsensusRequest(serializedRequests, 
request.getSearchIndex()));
+                .offer(new IndexedConsensusRequest(serializedRequests, 
request.getSearchIndex()))) {
+              impl.getIndexObject().wait();
+            }
+            ;
           } catch (InterruptedException e) {
             e.printStackTrace();
           } finally {
@@ -281,6 +284,7 @@ public class LogDispatcher {
                 bufferedRequest,
                 config.getReplication().getMaxRequestPerBatch() - 
bufferedRequest.size());
             maxIndexWhenBufferedRequestEmpty = impl.getIndex() + 1;
+            impl.getIndexObject().notifyAll();
           }
           // remove all request that searchIndex < startIndex
           Iterator<IndexedConsensusRequest> iterator = 
bufferedRequest.iterator();

Reply via email to