Skip to content

Commit f7ba063

Browse files
authored
fix error log caused by ClosedByInterruptException
1 parent 874a61d commit f7ba063

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.tsfile.exception;
21+
22+
import java.io.IOException;
23+
24+
public class StopReadTsFileByInterruptException extends IOException {}

tsfile/src/main/java/org/apache/tsfile/read/TsFileSequenceReader.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.tsfile.compress.IUnCompressor;
2626
import org.apache.tsfile.encoding.decoder.Decoder;
2727
import org.apache.tsfile.enums.TSDataType;
28+
import org.apache.tsfile.exception.StopReadTsFileByInterruptException;
2829
import org.apache.tsfile.exception.TsFileRuntimeException;
2930
import org.apache.tsfile.exception.TsFileStatisticsMistakesException;
3031
import org.apache.tsfile.file.MetaMarker;
@@ -298,6 +299,8 @@ public TsFileMetadata readFileMetadata() throws IOException {
298299
}
299300
}
300301
}
302+
} catch (StopReadTsFileByInterruptException e) {
303+
throw e;
301304
} catch (Exception e) {
302305
logger.error("Something error happened while reading file metadata of file {}", file);
303306
throw e;
@@ -523,6 +526,8 @@ public List<TimeseriesMetadata> readTimeseriesMetadata(
523526
TimeseriesMetadata timeseriesMetadata;
524527
try {
525528
timeseriesMetadata = TimeseriesMetadata.deserializeFrom(tsFileInput, true);
529+
} catch (StopReadTsFileByInterruptException e) {
530+
throw e;
526531
} catch (Exception e1) {
527532
logger.error(
528533
"Something error happened while deserializing TimeseriesMetadata of file {}", file);
@@ -728,6 +733,8 @@ public void getDevicesAndEntriesOfOneLeafNode(
728733
ByteBuffer nextBuffer = readData(startOffset, endOffset);
729734
MetadataIndexNode deviceLeafNode = MetadataIndexNode.deserializeFrom(nextBuffer);
730735
getDevicesOfLeafNode(deviceLeafNode, measurementNodeOffsetQueue);
736+
} catch (StopReadTsFileByInterruptException e) {
737+
throw e;
731738
} catch (Exception e) {
732739
logger.error("Something error happened while getting all devices of file {}", file);
733740
throw e;
@@ -795,6 +802,8 @@ private void getAllDeviceLeafNodeOffset(
795802
getAllDeviceLeafNodeOffset(
796803
MetadataIndexNode.deserializeFrom(nextBuffer), leafDeviceNodeOffsets);
797804
}
805+
} catch (StopReadTsFileByInterruptException e) {
806+
throw e;
798807
} catch (Exception e) {
799808
logger.error("Something error happened while getting all devices of file {}", file);
800809
throw e;
@@ -926,6 +935,8 @@ private void getAllPaths(
926935
metadataIndexNode.getNodeType(),
927936
queue);
928937
}
938+
} catch (StopReadTsFileByInterruptException e) {
939+
throw e;
929940
} catch (Exception e) {
930941
logger.error("Something error happened while getting all paths of file {}", file);
931942
throw e;
@@ -1144,6 +1155,8 @@ private void generateMetadataIndex(
11441155
}
11451156
}
11461157
}
1158+
} catch (StopReadTsFileByInterruptException e) {
1159+
throw e;
11471160
} catch (Exception e) {
11481161
logger.error("Something error happened while generating MetadataIndex of file {}", file);
11491162
throw e;
@@ -1193,6 +1206,8 @@ private void generateMetadataIndexUsingTsFileInput(
11931206
needChunkMetadata);
11941207
}
11951208
}
1209+
} catch (StopReadTsFileByInterruptException e) {
1210+
throw e;
11961211
} catch (Exception e) {
11971212
logger.error("Something error happened while generating MetadataIndex of file {}", file);
11981213
throw e;
@@ -1314,6 +1329,8 @@ protected Pair<MetadataIndexEntry, Long> getMetadataAndEndOffset(
13141329
return getMetadataAndEndOffset(
13151330
MetadataIndexNode.deserializeFrom(buffer), name, isDeviceLevel, exactSearch);
13161331
}
1332+
} catch (StopReadTsFileByInterruptException e) {
1333+
throw e;
13171334
} catch (Exception e) {
13181335
logger.error("Something error happened while deserializing MetadataIndex of file {}", file);
13191336
throw e;
@@ -1369,6 +1386,8 @@ public void readPlanIndex() throws IOException {
13691386
public ChunkHeader readChunkHeader(byte chunkType) throws IOException {
13701387
try {
13711388
return ChunkHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), chunkType);
1389+
} catch (StopReadTsFileByInterruptException e) {
1390+
throw e;
13721391
} catch (Throwable t) {
13731392
logger.warn("Exception {} happened while reading chunk header of {}", t.getMessage(), file);
13741393
throw t;
@@ -1383,6 +1402,8 @@ public ChunkHeader readChunkHeader(byte chunkType) throws IOException {
13831402
private ChunkHeader readChunkHeader(long position) throws IOException {
13841403
try {
13851404
return ChunkHeader.deserializeFrom(tsFileInput, position);
1405+
} catch (StopReadTsFileByInterruptException e) {
1406+
throw e;
13861407
} catch (Throwable t) {
13871408
logger.warn("Exception {} happened while reading chunk header of {}", t.getMessage(), file);
13881409
throw t;
@@ -1399,6 +1420,8 @@ private ChunkHeader readChunkHeader(long position) throws IOException {
13991420
public ByteBuffer readChunk(long position, int dataSize) throws IOException {
14001421
try {
14011422
return readData(position, dataSize);
1423+
} catch (StopReadTsFileByInterruptException e) {
1424+
throw e;
14021425
} catch (Throwable t) {
14031426
logger.warn("Exception {} happened while reading chunk of {}", t.getMessage(), file);
14041427
throw t;
@@ -1415,6 +1438,8 @@ public Chunk readMemChunk(long offset) throws IOException {
14151438
ChunkHeader header = readChunkHeader(offset);
14161439
ByteBuffer buffer = readChunk(offset + header.getSerializedSize(), header.getDataSize());
14171440
return new Chunk(header, buffer);
1441+
} catch (StopReadTsFileByInterruptException e) {
1442+
throw e;
14181443
} catch (Throwable t) {
14191444
logger.warn("Exception {} happened while reading chunk of {}", t.getMessage(), file);
14201445
throw t;
@@ -1434,6 +1459,8 @@ public Chunk readMemChunk(ChunkMetadata metaData) throws IOException {
14341459
readChunk(
14351460
metaData.getOffsetOfChunkHeader() + header.getSerializedSize(), header.getDataSize());
14361461
return new Chunk(header, buffer, metaData.getDeleteIntervalList(), metaData.getStatistics());
1462+
} catch (StopReadTsFileByInterruptException e) {
1463+
throw e;
14371464
} catch (Throwable t) {
14381465
logger.warn("Exception {} happened while reading chunk of {}", t.getMessage(), file);
14391466
throw t;
@@ -1500,6 +1527,8 @@ public MeasurementSchema getMeasurementSchema(List<IChunkMetadata> chunkMetadata
15001527
public PageHeader readPageHeader(TSDataType type, boolean hasStatistic) throws IOException {
15011528
try {
15021529
return PageHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), type, hasStatistic);
1530+
} catch (StopReadTsFileByInterruptException e) {
1531+
throw e;
15031532
} catch (Throwable t) {
15041533
logger.warn("Exception {} happened while reading page header of {}", t.getMessage(), file);
15051534
throw t;
@@ -1618,6 +1647,8 @@ protected ByteBuffer readData(long position, int totalSize) throws IOException {
16181647
protected ByteBuffer readData(long start, long end) throws IOException {
16191648
try {
16201649
return readData(start, (int) (end - start));
1650+
} catch (StopReadTsFileByInterruptException e) {
1651+
throw e;
16211652
} catch (Throwable t) {
16221653
logger.warn("Exception {} happened while reading data of {}", t.getMessage(), file);
16231654
throw t;
@@ -1947,6 +1978,8 @@ public long selfCheckWithInfo(
19471978
return TsFileCheckStatus.COMPLETE_FILE;
19481979
}
19491980
}
1981+
} catch (StopReadTsFileByInterruptException e) {
1982+
throw e;
19501983
} catch (IOException e) {
19511984
logger.error("Error occurred while fast checking TsFile.");
19521985
throw e;
@@ -1960,6 +1993,8 @@ public long selfCheckWithInfo(
19601993
long tscheckStatus = TsFileCheckStatus.COMPLETE_FILE;
19611994
try {
19621995
tscheckStatus = checkChunkAndPagesStatistics(chunkMetadata);
1996+
} catch (StopReadTsFileByInterruptException e) {
1997+
throw e;
19631998
} catch (IOException e) {
19641999
logger.error("Error occurred while checking the statistics of chunk and its pages");
19652000
throw e;
@@ -2392,6 +2427,8 @@ private void collectEachLeafMeasurementNodeOffsetRange(
23922427
}
23932428
collectEachLeafMeasurementNodeOffsetRange(readData(startOffset, endOffset), queue);
23942429
}
2430+
} catch (StopReadTsFileByInterruptException e) {
2431+
throw e;
23952432
} catch (Exception e) {
23962433
logger.error(
23972434
"Error occurred while collecting offset ranges of measurement nodes of file {}", file);

tsfile/src/main/java/org/apache/tsfile/read/reader/LocalTsFileInput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public long size() throws IOException {
4848
try {
4949
return channel.size();
5050
} catch (IOException e) {
51-
logger.error("Error happened while getting {} size", filePath);
51+
logger.warn("Error happened while getting {} size", filePath);
5252
throw e;
5353
}
5454
}
@@ -58,7 +58,7 @@ public long position() throws IOException {
5858
try {
5959
return channel.position();
6060
} catch (IOException e) {
61-
logger.error("Error happened while getting {} current position", filePath);
61+
logger.warn("Error happened while getting {} current position", filePath);
6262
throw e;
6363
}
6464
}
@@ -69,7 +69,7 @@ public TsFileInput position(long newPosition) throws IOException {
6969
channel.position(newPosition);
7070
return this;
7171
} catch (IOException e) {
72-
logger.error("Error happened while changing {} position to {}", filePath, newPosition);
72+
logger.warn("Error happened while changing {} position to {}", filePath, newPosition);
7373
throw e;
7474
}
7575
}

0 commit comments

Comments
 (0)