You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ch...@apache.org on 2025/11/04 18:32:38 UTC
(ozone) 01/02: HDDS-13799. Revert "HDDS-12982. Reduce log level for snapshot validation failure (#8851)" (#9162)
This is an automated email from the ASF dual-hosted git repository.
chungen pushed a commit to branch ozone-2.1
in repository https://gitbox.apache.org/repos/asf/ozone.git
commit 20f872f0bd9f18a58b1c77f17fbf6f043b2d1a8a
Author: Wei-Chiu Chuang <we...@apache.org>
AuthorDate: Fri Oct 17 19:18:19 2025 -0700
HDDS-13799. Revert "HDDS-12982. Reduce log level for snapshot validation failure (#8851)" (#9162)
(cherry picked from commit 3fee4c21bd5c7a876ce72716c15f4487429f8391)
---
.../hadoop/ozone/om/request/key/OMKeyPurgeRequest.java | 7 ++-----
.../org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java | 12 +++++++-----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java
index 5fe932c4a09..d4da86ef090 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java
@@ -97,11 +97,8 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut
// redundant tombstone entry in the deletedTable. It is better to skip the transaction.
UUID expectedPreviousSnapshotId = purgeKeysRequest.getExpectedPreviousSnapshotID().hasUuid()
? fromProtobuf(purgeKeysRequest.getExpectedPreviousSnapshotID().getUuid()) : null;
- if (!validatePreviousSnapshotId(fromSnapshotInfo, omMetadataManager.getSnapshotChainManager(),
- expectedPreviousSnapshotId)) {
- return new OMKeyPurgeResponse(createErrorOMResponse(omResponse,
- new OMException("Snapshot validation failed", OMException.ResultCodes.INVALID_REQUEST)));
- }
+ validatePreviousSnapshotId(fromSnapshotInfo, omMetadataManager.getSnapshotChainManager(),
+ expectedPreviousSnapshotId);
}
} catch (IOException e) {
LOG.error("Error occurred while performing OmKeyPurge. ", e);
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java
index ea6d88c8e19..63e7e38d518 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java
@@ -292,17 +292,19 @@ public static UUID getLatestPathSnapshotId(String volumeName, String bucketName,
return snapshotChainManager.getLatestPathSnapshotId(snapshotPath);
}
- public static boolean validatePreviousSnapshotId(SnapshotInfo snapshotInfo,
+ // Validates the previous path snapshotId for given a snapshotInfo. In case snapshotInfo is
+ // null, the snapshotInfo would be considered as AOS and previous snapshot becomes the latest snapshot in the global
+ // snapshot chain. Would throw OMException if validation fails otherwise function would pass.
+ public static void validatePreviousSnapshotId(SnapshotInfo snapshotInfo,
SnapshotChainManager snapshotChainManager,
UUID expectedPreviousSnapshotId) throws IOException {
UUID previousSnapshotId = snapshotInfo == null ? snapshotChainManager.getLatestGlobalSnapshotId() :
SnapshotUtils.getPreviousSnapshotId(snapshotInfo, snapshotChainManager);
if (!Objects.equals(expectedPreviousSnapshotId, previousSnapshotId)) {
- LOG.warn("Snapshot validation failed. Expected previous snapshotId : " +
- expectedPreviousSnapshotId + " but was " + previousSnapshotId);
- return false;
+ throw new OMException("Snapshot validation failed. Expected previous snapshotId : " +
+ expectedPreviousSnapshotId + " but was " + previousSnapshotId,
+ OMException.ResultCodes.INVALID_REQUEST);
}
- return true;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org