You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/05/19 11:23:04 UTC

[iotdb] branch master updated: Print file name while meeting error in reading or deserializing (#5959)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 271148e072 Print file name while meeting error in reading or deserializing (#5959)
271148e072 is described below

commit 271148e0729a0d9c88857a0f6315e5973d0c6db1
Author: Jackie Tien <ja...@gmail.com>
AuthorDate: Thu May 19 19:22:58 2022 +0800

    Print file name while meeting error in reading or deserializing (#5959)
---
 .../iotdb/tsfile/read/TsFileSequenceReader.java    | 52 +++++++++++++++++-----
 1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
index 3c063d40de..02a226a4ef 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
@@ -1041,7 +1041,12 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @throws IOException io error
    */
   public ChunkHeader readChunkHeader(byte chunkType) throws IOException {
-    return ChunkHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), chunkType);
+    try {
+      return ChunkHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), chunkType);
+    } catch (Throwable t) {
+      logger.error("Exception happened while reading chunk header of {}", file, t);
+      throw t;
+    }
   }
 
   /**
@@ -1051,7 +1056,12 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @param chunkHeaderSize the size of chunk's header
    */
   private ChunkHeader readChunkHeader(long position, int chunkHeaderSize) throws IOException {
-    return ChunkHeader.deserializeFrom(tsFileInput, position, chunkHeaderSize);
+    try {
+      return ChunkHeader.deserializeFrom(tsFileInput, position, chunkHeaderSize);
+    } catch (Throwable t) {
+      logger.error("Exception happened while reading chunk header of {}", file, t);
+      throw t;
+    }
   }
 
   /**
@@ -1062,7 +1072,12 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @return the pages of this chunk
    */
   private ByteBuffer readChunk(long position, int dataSize) throws IOException {
-    return readData(position, dataSize);
+    try {
+      return readData(position, dataSize);
+    } catch (Throwable t) {
+      logger.error("Exception happened while reading chunk of {}", file, t);
+      throw t;
+    }
   }
 
   /**
@@ -1072,12 +1087,17 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @return -chunk
    */
   public Chunk readMemChunk(ChunkMetadata metaData) throws IOException {
-    int chunkHeadSize = ChunkHeader.getSerializedSize(metaData.getMeasurementUid());
-    ChunkHeader header = readChunkHeader(metaData.getOffsetOfChunkHeader(), chunkHeadSize);
-    ByteBuffer buffer =
-        readChunk(
-            metaData.getOffsetOfChunkHeader() + header.getSerializedSize(), header.getDataSize());
-    return new Chunk(header, buffer, metaData.getDeleteIntervalList(), metaData.getStatistics());
+    try {
+      int chunkHeadSize = ChunkHeader.getSerializedSize(metaData.getMeasurementUid());
+      ChunkHeader header = readChunkHeader(metaData.getOffsetOfChunkHeader(), chunkHeadSize);
+      ByteBuffer buffer =
+          readChunk(
+              metaData.getOffsetOfChunkHeader() + header.getSerializedSize(), header.getDataSize());
+      return new Chunk(header, buffer, metaData.getDeleteIntervalList(), metaData.getStatistics());
+    } catch (Throwable t) {
+      logger.error("Exception happened while reading chunk of {}", file, t);
+      throw t;
+    }
   }
 
   /**
@@ -1103,7 +1123,12 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @param type given tsfile data type
    */
   public PageHeader readPageHeader(TSDataType type, boolean hasStatistic) throws IOException {
-    return PageHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), type, hasStatistic);
+    try {
+      return PageHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), type, hasStatistic);
+    } catch (Throwable t) {
+      logger.error("Exception happened while reading page header of {}", file, t);
+      throw t;
+    }
   }
 
   public long position() throws IOException {
@@ -1216,7 +1241,12 @@ public class TsFileSequenceReader implements AutoCloseable {
    * @return data that been read.
    */
   protected ByteBuffer readData(long start, long end) throws IOException {
-    return readData(start, (int) (end - start));
+    try {
+      return readData(start, (int) (end - start));
+    } catch (Throwable t) {
+      logger.error("Exception happened while reading data of {}", file, t);
+      throw t;
+    }
   }
 
   /** notice, the target bytebuffer are not flipped. */