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

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


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new 9b66d5e528e [Backport 1.3] Avoid read lock when restoring degraded 
time index (#18190)
9b66d5e528e is described below

commit 9b66d5e528e6997e8c6c30b718e35ee36b5a6774
Author: Jiang Tian <[email protected]>
AuthorDate: Mon Jul 13 14:07:26 2026 +0800

    [Backport 1.3] Avoid read lock when restoring degraded time index (#18190)
    
    * Avoid readLock when serializing TimeIndex.
    
    * Fix time index deserialization compatibility on dev/1.3
---
 .../storageengine/dataregion/tsfile/TsFileResource.java | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileResource.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileResource.java
index 7505b3e406b..f5df3066809 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileResource.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileResource.java
@@ -281,7 +281,7 @@ public class TsFileResource implements Cloneable {
       return timeIndex;
     }
 
-    return buildDeviceTimeIndex();
+    return deserializeTimeIndexFromResourceFile();
   }
 
   /** deserialize from disk */
@@ -506,11 +506,8 @@ public class TsFileResource implements Cloneable {
       if (!resourceFileExists()) {
         throw new IOException("resource file not found");
       }
-      try (InputStream inputStream =
-          FSFactoryProducer.getFSFactory()
-              .getBufferedInputStream(file.getPath() + RESOURCE_SUFFIX)) {
-        ReadWriteIOUtils.readByte(inputStream);
-        ITimeIndex timeIndexFromResourceFile = 
ITimeIndex.createTimeIndex(inputStream);
+      try {
+        ITimeIndex timeIndexFromResourceFile = 
deserializeTimeIndexFromResourceFile();
         if (!(timeIndexFromResourceFile instanceof DeviceTimeIndex)) {
           throw new IOException("cannot build DeviceTimeIndex from resource " 
+ file.getPath());
         }
@@ -524,6 +521,14 @@ public class TsFileResource implements Cloneable {
     }
   }
 
+  private ITimeIndex deserializeTimeIndexFromResourceFile() throws IOException 
{
+    try (InputStream inputStream =
+        FSFactoryProducer.getFSFactory().getBufferedInputStream(file.getPath() 
+ RESOURCE_SUFFIX)) {
+      ReadWriteIOUtils.readByte(inputStream);
+      return ITimeIndex.createTimeIndex(inputStream);
+    }
+  }
+
   /** Only used for compaction to validate tsfile. */
   public ITimeIndex getTimeIndex() {
     return timeIndex;

Reply via email to