This is an automated email from the ASF dual-hosted git repository.
tanxinyu 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 ad675479751 [region migration] Snapshot source file not exists problem
debugging #13214
ad675479751 is described below
commit ad6754797517dfb130a018a78c342e68de875b1f
Author: Li Yu Heng <[email protected]>
AuthorDate: Mon Aug 19 14:46:40 2024 +0800
[region migration] Snapshot source file not exists problem debugging #13214
---
.../dataregion/snapshot/SnapshotTaker.java | 34 ++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
index 7f046940afe..5dae1448e11 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
@@ -34,8 +34,10 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.util.Arrays;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.TimeUnit;
/**
* SnapshotTaker takes data snapshot for a DataRegion in one time. It does so
by creating hard link
@@ -221,14 +223,42 @@ public class SnapshotTaker {
if (!target.getParentFile().exists()) {
LOGGER.error("Hard link target dir {} doesn't exist",
target.getParentFile());
}
- if (!source.exists()) {
- LOGGER.error("Hard link source file {} doesn't exist", source);
+ if (!checkHardLinkSourceFile(source)) {
+ return;
}
Files.deleteIfExists(target.toPath());
Files.createLink(target.toPath(), source.toPath());
snapshotLogger.logFile(source);
}
+ /** For "source file not exists" problem (jira787) debugging */
+ private boolean checkHardLinkSourceFile(File source) {
+ int retry = 10;
+ while (!source.exists() && retry > 0) {
+ LOGGER.warn(
+ "Hard link source file {} doesn't exist, will retry for {}
times...", source, retry);
+ try {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(1));
+ } catch (InterruptedException ignore) {
+ Thread.currentThread().interrupt();
+ }
+ retry--;
+ }
+ if (!source.exists()) {
+ File parent = source.getParentFile();
+ LOGGER.error("Hard link source file {} doesn't exist, this file will be
ignored.", source);
+ String tryMsg = "Try to show all files in parent dir...";
+ if (parent == null) {
+ tryMsg += "Cannot show files because parent dir is null";
+ } else {
+ tryMsg += Arrays.toString(parent.listFiles());
+ }
+ LOGGER.error(tryMsg);
+ return false;
+ }
+ return true;
+ }
+
private void copyFile(File target, File source) throws IOException {
if (!target.getParentFile().exists()) {
LOGGER.error("Copy target dir {} doesn't exist", target.getParentFile());