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

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

commit 1b507c9503c93e9037a35d1e913841823cef64a6
Author: Tian Jiang <[email protected]>
AuthorDate: Mon Jul 6 17:38:08 2026 +0800

    Persist writer meta out of lock
---
 .../apache/iotdb/consensus/iot/IoTConsensusServerImpl.java  | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
 
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
index 07d1f2593b2..eefdeaa36a8 100644
--- 
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
+++ 
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
@@ -330,7 +330,9 @@ public class IoTConsensusServerImpl {
           }
           searchIndex.incrementAndGet();
         }
-        updateWriterMetaOnSuccess(indexedConsensusRequest);
+        latestWriterMeta =
+            new WriterMeta(
+                indexedConsensusRequest.getLocalSeq(), 
indexedConsensusRequest.getPhysicalTime());
         // statistic the time of offering request into queue
         ioTConsensusServerMetrics.recordOfferRequestToQueueTime(
             System.nanoTime() - writeToStateMachineEndTime);
@@ -349,6 +351,7 @@ public class IoTConsensusServerImpl {
       return result;
     } finally {
       stateMachineLock.unlock();
+      persistLatestWriterMeta(false);
     }
   }
 
@@ -1041,9 +1044,7 @@ public class IoTConsensusServerImpl {
   }
 
   private void updateWriterMetaOnSuccess(final IndexedConsensusRequest 
indexedConsensusRequest) {
-    latestWriterMeta =
-        new WriterMeta(
-            indexedConsensusRequest.getLocalSeq(), 
indexedConsensusRequest.getPhysicalTime());
+
     persistLatestWriterMeta(false);
   }
 
@@ -1062,8 +1063,8 @@ public class IoTConsensusServerImpl {
     synchronized (writerMetaPersistLock) {
       final WriterMeta latestMeta = latestWriterMeta;
       if (latestMeta == null
-          || (latestMeta.getLastAllocatedLocalSeq() == 
lastPersistedWriterLocalSeq
-              && latestMeta.getLastAssignedPhysicalTimeMs() == 
lastPersistedWriterPhysicalTime)) {
+          || (latestMeta.getLastAllocatedLocalSeq() <= 
lastPersistedWriterLocalSeq
+              && latestMeta.getLastAssignedPhysicalTimeMs() <= 
lastPersistedWriterPhysicalTime)) {
         return;
       }
 

Reply via email to