This is an automated email from the ASF dual-hosted git repository.
rong 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 860dd1c7340 Pipe: Fixed the issue where the storage engine referenced
an incorrect Mod file after the Mod file was cleaned up after the Receiver
thread exited. (#15235)
860dd1c7340 is described below
commit 860dd1c734067bd37f4d9f74a9eaa8fb374db513
Author: Zhenyu Luo <[email protected]>
AuthorDate: Mon Mar 31 18:01:50 2025 +0800
Pipe: Fixed the issue where the storage engine referenced an incorrect Mod
file after the Mod file was cleaned up after the Receiver thread exited.
(#15235)
---
.../db/storageengine/dataregion/DataRegion.java | 82 ++++++++++++----------
1 file changed, 43 insertions(+), 39 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
index 7c26da02814..961968d601f 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
@@ -3092,52 +3092,56 @@ public class DataRegion implements IDataRegionForQuery {
final File modFileToLoad =
fsFactory.getFile(tsFileToLoad.getAbsolutePath() +
ModificationFile.FILE_SUFFIX);
- if (modFileToLoad.exists()) {
- // when successfully loaded, the filepath of the resource will be
changed to the IoTDB data
- // dir, so we can add a suffix to find the old modification file.
- final File targetModFile =
- fsFactory.getFile(targetFile.getAbsolutePath() +
ModificationFile.FILE_SUFFIX);
- try {
- RetryUtils.retryOnException(
- () -> {
- Files.deleteIfExists(targetModFile.toPath());
- return null;
- });
- } catch (final IOException e) {
- logger.warn("Cannot delete localModFile {}", targetModFile, e);
- }
- try {
- final long modFileSize = modFileToLoad.length();
- if (deleteOriginFile) {
- RetryUtils.retryOnException(
- () -> {
- FileUtils.moveFile(modFileToLoad, targetModFile);
- return null;
- });
- } else {
+ try {
+ if (modFileToLoad.exists()) {
+ // when successfully loaded, the filepath of the resource will be
changed to the IoTDB data
+ // dir, so we can add a suffix to find the old modification file.
+ final File targetModFile =
+ fsFactory.getFile(targetFile.getAbsolutePath() +
ModificationFile.FILE_SUFFIX);
+ try {
RetryUtils.retryOnException(
() -> {
- Files.copy(modFileToLoad.toPath(), targetModFile.toPath());
+ Files.deleteIfExists(targetModFile.toPath());
return null;
});
+ } catch (final IOException e) {
+ logger.warn("Cannot delete localModFile {}", targetModFile, e);
}
+ try {
+ final long modFileSize = modFileToLoad.length();
+ if (deleteOriginFile) {
+ RetryUtils.retryOnException(
+ () -> {
+ FileUtils.moveFile(modFileToLoad, targetModFile);
+ return null;
+ });
+ } else {
+ RetryUtils.retryOnException(
+ () -> {
+ Files.copy(modFileToLoad.toPath(), targetModFile.toPath());
+ return null;
+ });
+ }
- FileMetrics.getInstance().increaseModFileNum(1);
- FileMetrics.getInstance().increaseModFileSize(modFileSize);
- } catch (final IOException e) {
- logger.warn(
- "File renaming failed when loading .mod file. Origin: {}, Target:
{}",
- modFileToLoad.getAbsolutePath(),
- targetModFile.getAbsolutePath(),
- e);
- throw new LoadFileException(
- String.format(
- "File renaming failed when loading .mod file. Origin: %s,
Target: %s, because %s",
- modFileToLoad.getAbsolutePath(),
targetModFile.getAbsolutePath(), e.getMessage()));
- } finally {
- // ModFile will be updated during the next call to `getModFile`
- tsFileResource.setModFile(null);
+ FileMetrics.getInstance().increaseModFileNum(1);
+ FileMetrics.getInstance().increaseModFileSize(modFileSize);
+ } catch (final IOException e) {
+ logger.warn(
+ "File renaming failed when loading .mod file. Origin: {},
Target: {}",
+ modFileToLoad.getAbsolutePath(),
+ targetModFile.getAbsolutePath(),
+ e);
+ throw new LoadFileException(
+ String.format(
+ "File renaming failed when loading .mod file. Origin: %s,
Target: %s, because %s",
+ modFileToLoad.getAbsolutePath(),
+ targetModFile.getAbsolutePath(),
+ e.getMessage()));
+ }
}
+ } finally {
+ // ModFile will be updated during the next call to `getModFile`
+ tsFileResource.setModFile(null);
}
// Listen before the tsFile is added into tsFile manager to avoid it being
compacted