You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/07/26 14:31:16 UTC
[GitHub] [iotdb] THUMarkLau commented on a diff in pull request #6782: [IOTDB-3771] Fix cannot take snapshot when the data dir and snapshot dir is on different disk
THUMarkLau commented on code in PR #6782:
URL: https://github.com/apache/iotdb/pull/6782#discussion_r930040442
##########
server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java:
##########
@@ -117,83 +208,152 @@ public boolean takeFullSnapshot(String snapshotDirPath, boolean flushBeforeSnaps
} finally {
manager.readUnlock();
}
+ return true;
+ }
+
+ private boolean createSnapshotInAnotherDisk(File snapshotDir) {
+ for (String dataDir : IoTDBDescriptor.getInstance().getConfig().getDataDirs()) {
+ File seqDir =
+ new File(
+ dataDir,
+ "sequence"
+ + File.separator
+ + dataRegion.getLogicalStorageGroupName()
+ + File.separator
+ + dataRegion.getDataRegionId());
+ File unseqDir =
+ new File(
+ dataDir,
+ "unsequence"
+ + File.separator
+ + dataRegion.getLogicalStorageGroupName()
+ + File.separator
+ + dataRegion.getDataRegionId());
+ File localSeqSnapshotDir =
+ new File(
+ dataDir,
+ "snapshot"
+ + File.separator
+ + "sequence"
+ + File.separator
+ + snapshotDir.getName()
+ + File.separator
+ + dataRegion.getLogicalStorageGroupName()
+ + File.separator
+ + dataRegion.getDataRegionId());
+ File localUnseqSnapshotDir =
+ new File(
+ dataDir,
+ "snapshot"
+ + File.separator
+ + "unsequence"
+ + File.separator
+ + snapshotDir.getName()
+ + File.separator
+ + dataRegion.getLogicalStorageGroupName()
+ + File.separator
+ + dataRegion.getDataRegionId());
+ if (!localSeqSnapshotDir.mkdirs()) {
+ LOGGER.warn("Failed to create local snapshot dir {}", localSeqSnapshotDir);
+ return false;
+ }
+ List<Long> timePartitions = dataRegion.getTimePartitions();
+ TsFileManager manager = dataRegion.getTsFileManager();
+ manager.readLock();
+ for (long timePartition : timePartitions) {
+ File seqTimePartitionDir = new File(seqDir, String.valueOf(timePartition));
+ File seqTimePartitionSnapshotDir =
+ new File(localSeqSnapshotDir, String.valueOf(timePartition));
- LOGGER.info(
- "Successfully take snapshot for {}-{}, snapshot directory is {}",
- dataRegion.getLogicalStorageGroupName(),
- dataRegion.getDataRegionId(),
- snapshotDirPath);
+ try {
+ createFileSnapshotToTargetOne(seqTimePartitionDir, seqTimePartitionSnapshotDir);
+ } catch (IOException e) {
+ LOGGER.error(
+ "Failed to create snapshot for {}-{}",
+ dataRegion.getLogicalStorageGroupName(),
+ dataRegion.getDataRegionId(),
+ e);
+ } finally {
+ cleanUpWhenFail(snapshotDir);
Review Comment:
This finally is unnecessary, so I've deleted it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org