This is an automated email from the ASF dual-hosted git repository. shuwenwei pushed a commit to branch object_type in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0eac637cb206275d60fa4bf210d529e1a0d84dd0 Author: shuwenwei <[email protected]> AuthorDate: Mon Jul 14 15:18:24 2025 +0800 fix ttl deletion --- .../java/org/apache/iotdb/TableModelSessionPoolExample.java | 2 +- .../apache/iotdb/db/storageengine/rescon/disk/TierManager.java | 10 ++++++++++ .../main/java/org/apache/iotdb/db/utils/ObjectTypeUtils.java | 9 +++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java b/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java index 0109cacc2c0..811b034eb4b 100644 --- a/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java +++ b/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java @@ -141,7 +141,7 @@ public class TableModelSessionPoolExample { System.out.println("Correct device leader URL: " + correctURL); try { String errorDbURL = - session.getDeviceLeaderURL("test3", Arrays.asList("test1", "1", "3"), isSetTag, 66); + session.getDeviceLeaderURL("test3", Arrays.asList("test1", "1", "3"), isSetTag, 66); System.out.println("Error dbName device leader URL: " + errorDbURL); } catch (StatementExecutionException e) { System.out.println(e.getMessage()); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/TierManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/TierManager.java index 61bb6ffafba..6355880cebd 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/TierManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/TierManager.java @@ -254,11 +254,21 @@ public class TierManager { } public Optional<File> getAbsoluteObjectFilePath(String filePath) { + return getAbsoluteObjectFilePath(filePath, false); + } + + public Optional<File> getAbsoluteObjectFilePath(String filePath, boolean needTempFile) { for (String objectDir : objectDirs) { File objectFile = FSFactoryProducer.getFSFactory().getFile(objectDir, filePath); if (objectFile.exists()) { return Optional.of(objectFile); } + if (needTempFile) { + if (new File(objectFile.getPath() + ".tmp").exists() + || new File(objectFile.getPath() + ".back").exists()) { + return Optional.of(objectFile); + } + } } return Optional.empty(); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ObjectTypeUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ObjectTypeUtils.java index c66e3ffd05d..ba33a964228 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ObjectTypeUtils.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ObjectTypeUtils.java @@ -50,20 +50,21 @@ public class ObjectTypeUtils { return file.get(); } - public static Optional<File> getNullableObjectPathFromBinary(Binary binary) { + public static Optional<File> getNullableObjectPathFromBinary( + Binary binary, boolean needTempFile) { byte[] bytes = binary.getValues(); String relativeObjectFilePath = new String(bytes, 8, bytes.length - 8, TSFileConfig.STRING_CHARSET); - return TIER_MANAGER.getAbsoluteObjectFilePath(relativeObjectFilePath); + return TIER_MANAGER.getAbsoluteObjectFilePath(relativeObjectFilePath, needTempFile); } public static void deleteObjectPathFromBinary(Binary binary) { - Optional<File> file = ObjectTypeUtils.getNullableObjectPathFromBinary(binary); + Optional<File> file = ObjectTypeUtils.getNullableObjectPathFromBinary(binary, true); if (!file.isPresent()) { return; } File tmpFile = new File(file.get().getPath() + ".tmp"); - File bakFile = new File(file.get().getPath() + ".bak"); + File bakFile = new File(file.get().getPath() + ".back"); logger.info("Remove object file {}", file.get().getAbsolutePath()); for (int i = 0; i < 2; i++) { try {
