smengcl commented on code in PR #10774:
URL: https://github.com/apache/ozone/pull/10774#discussion_r3708658674
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/defrag/SnapshotDefragService.java:
##########
@@ -574,19 +574,36 @@ OmMetadataManagerImpl createCheckpoint(SnapshotInfo
snapshotInfo,
try (UncheckedAutoCloseableSupplier<OmSnapshot> snapshot =
omSnapshotManager.getActiveSnapshot(
snapshotInfo.getVolumeName(), snapshotInfo.getBucketName(),
snapshotInfo.getName())) {
DBCheckpoint checkpoint =
snapshot.get().getMetadataManager().getStore().getCheckpoint(tmpDefragDir,
true);
- try (OmMetadataManagerImpl metadataManagerBeforeTruncate =
- createDefragCheckpointMetadataManager(checkpoint, false)) {
- DBStore dbStore = metadataManagerBeforeTruncate.getStore();
- for (String table : metadataManagerBeforeTruncate.listTableNames()) {
- if (!incrementalColumnFamilies.contains(table)) {
- dbStore.dropTable(table);
+ Path checkpointLocation = checkpoint.getCheckpointLocation();
+ boolean checkpointSuccessful = false;
+ try {
+ try (OmMetadataManagerImpl metadataManagerBeforeTruncate =
+ createDefragCheckpointMetadataManager(checkpoint, false)) {
+ DBStore dbStore = metadataManagerBeforeTruncate.getStore();
+ for (String table : metadataManagerBeforeTruncate.listTableNames()) {
+ if (!incrementalColumnFamilies.contains(table)) {
+ dbStore.dropTable(table);
+ }
+ }
+ } catch (Exception e) {
+ throw new IOException("Failed to close checkpoint of snapshot: " +
snapshotInfo.getSnapshotId(), e);
+ }
+ // This will recreate the column families in the checkpoint.
+ OmMetadataManagerImpl result =
createDefragCheckpointMetadataManager(checkpoint, false);
+ checkpointSuccessful = true;
+ return result;
+ } finally {
+ if (!checkpointSuccessful && Files.exists(checkpointLocation)) {
+ try {
+ deleteDirectory(checkpointLocation);
+ } catch (IOException cleanupException) {
+ LOG.error("Failed to clean up checkpoint directory {} for
snapshot: {} (ID: {}). " +
+ "Disk spacde may not be freed. Manual cleanup may be
required.",
Review Comment:
nit: typo
```suggestion
"Disk space may not be freed. Manual cleanup may be
required.",
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]