You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "swamirishi (via GitHub)" <gi...@apache.org> on 2023/08/25 06:11:39 UTC
[GitHub] [ozone] swamirishi opened a new pull request, #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
swamirishi opened a new pull request, #5223:
URL: https://github.com/apache/ozone/pull/5223
## What changes were proposed in this pull request?
SnapshotCreateRequest creates snapshotInfo created time in pre-execute phase whose order need not be the same as the ratis log ordering. So 2 consecutive snapshot created in the snapshot info table need not be in increasing order of created time. SnapshotChainManager on om restart tries to load the snapshot in the increasing order of their created time. Thus throws a SnapshotChainCorruption exception in this case as it previous snapshot is not loaded but SnapshotChainManager expects that the previous snapshot be loaded before trying to load the current snapshot.
Thus instead of ordering snapshot on their created time. The changes proposes to create a forward linked list for the snapshot chain based on the previousSnapshotGlobalId from the snapshotInfo and iterates through the linked list in the same order. Also added a few debug logs for the same.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-9215
## How was this patch tested?
Existing Unit tests & adding more Unit Tests.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308035720
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
Review Comment:
nit: `...there are %d snapshot in...` or nodes whatever you feel like.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1307749070
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +286,56 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(Map<UUID, UUID> snapshotChain)
Review Comment:
Added another testcase for the same.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308322792
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308340024
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1305970863
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +234,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> snapshotChain = new HashMap<>();
Review Comment:
nit: I think variable name and comment are not correct. To me, it is not a chain. It is a map of snapshot to next snapshot. Chain is something order is maintain.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +286,56 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(Map<UUID, UUID> snapshotChain)
Review Comment:
Should we add similar test for path level previous?
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -243,10 +246,37 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
while (keyIter.hasNext()) {
kv = keyIter.next();
- snaps.put(kv.getValue().getCreationTime(), kv.getValue());
+ SnapshotInfo snapshotInfo = kv.getValue();
+ snaps.put(kv.getValue().getSnapshotId(), snapshotInfo);
+ if (snapshotInfo.getGlobalPreviousSnapshotId() != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Global Snapshot chain link {} -> {}",
+ snapshotInfo.getGlobalPreviousSnapshotId(),
+ snapshotInfo.getSnapshotId());
+ }
+ // Adding edge to the linked list. prevGlobalSnapId -> snapId
+ snapshotChain.put(snapshotInfo.getGlobalPreviousSnapshotId(),
+ snapshotInfo.getSnapshotId());
+ } else {
+ head = snapshotInfo.getSnapshotId();
+ }
+ }
+ int size = 0;
+ UUID prev = null;
+ while (head != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Adding Snapshot Info: {}", snaps.get(head));
+ }
+ addSnapshot(snaps.get(head));
+ size += 1;
+ prev = head;
+ head = snapshotChain.get(head);
}
- for (SnapshotInfo snapshotInfo : snaps.values()) {
- addSnapshot(snapshotInfo);
+ if (size != snaps.size()) {
+ throw new IOException(String.format("Snapshot chain corruption. " +
Review Comment:
nit:
1. Please change it to `IllegalStateException`.
2. Exception message could be better. May be `(Snapshot chain corruption. All snapshots have not been added to the snapshot chain. Last snapshot added to chain : %s", prev)`.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -65,14 +76,15 @@ public void setup() throws Exception {
private SnapshotInfo createSnapshotInfo(UUID snapshotID,
UUID pathPrevID,
- UUID globalPrevID) {
+ UUID globalPrevID,
+ long creationTime) {
return new SnapshotInfo.Builder()
.setSnapshotId(snapshotID)
.setName("test")
.setVolumeName("vol1")
.setBucketName("bucket1")
.setSnapshotStatus(SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)
- .setCreationTime(Time.now())
+ .setCreationTime(creationTime)
Review Comment:
qq: Do we really need pass creation time? Snapshot chain construction is independent of it? Isn't 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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308339578
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +273,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> nextSnapshotIdMap = new HashMap<>();
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +290,68 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(nodes, Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(nodes, Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(nodes, Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(nodes, Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidGlobalChainFromLoadFromTable(
+ List<UUID> snapshotIDs, Map<UUID, UUID> snapshotChain) throws Exception {
+ Table<String, SnapshotInfo> snapshotInfo =
+ omMetadataManager.getSnapshotInfoTable();
+ for (UUID snapshotID : snapshotIDs) {
+ snapshotInfo.put(snapshotID.toString(),
+ createSnapshotInfo(snapshotID, snapshotChain.get(snapshotID),
+ snapshotChain.get(snapshotID), System.currentTimeMillis()));
+ }
+ Assertions.assertThrows(IllegalStateException.class,
+ () -> new SnapshotChainManager(omMetadataManager));
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(List<UUID> snapshotIDs,
+ Map<UUID, UUID> snapshotChain) throws Exception {
+ Table<String, SnapshotInfo> snapshotInfo =
+ omMetadataManager.getSnapshotInfoTable();
+ UUID prevSnapshotId = null;
+ for (UUID snapshotID : snapshotIDs) {
+ snapshotInfo.put(snapshotID.toString(),
+ createSnapshotInfo(snapshotID, snapshotChain.get(snapshotID),
+ prevSnapshotId, System.currentTimeMillis()));
+ prevSnapshotId = snapshotID;
+ }
+ Assertions.assertThrows(RuntimeException.class,
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1309310280
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -239,8 +253,10 @@ public void testDeleteSnapshot() throws Exception {
assertEquals(snapshotID3, chainManager.previousGlobalSnapshot(snapshotID2));
}
- @Test
- public void testChainFromLoadFromTable() throws Exception {
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testChainFromLoadFromTable(boolean increasingTIme)
Review Comment:
You are right, but one change will run either the increasing one or the decreasing one. We should cover both the scenarios for all the changes going forward.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1309097946
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -92,20 +114,38 @@ private void addSnapshotGlobal(UUID snapshotID,
/**
* Add snapshot to bucket snapshot chain(path based).
*/
- private void addSnapshotPath(String snapshotPath,
- UUID snapshotID,
- UUID prevPathID) throws IOException {
+ private void addSnapshotPath(String snapshotPath, UUID snapshotID,
+ UUID prevPathID) {
// On add snapshot, set previous snapshot entry nextSnapshotId = snapshotId
if (prevPathID != null &&
((!snapshotChainByPath.containsKey(snapshotPath)) ||
(!snapshotChainByPath.get(snapshotPath).containsKey(prevPathID)))) {
- throw new IOException(String.format("Snapshot chain corruption. " +
- "Previous snapshotId: %s is set for snapshotId: %s but no " +
- "associated snapshot found in snapshot chain.", prevPathID,
- snapshotID));
+ throw new IllegalStateException(String.format(
+ "Path Snapshot chain corruption. Previous snapshotId: %s is set " +
+ "for snapshotId: %s but no associated snapshot found in " +
+ "snapshot chain.", prevPathID, snapshotID));
+ }
+
+ if (prevPathID == null && snapshotChainByPath.containsKey(snapshotPath) &&
+ !snapshotChainByPath.get(snapshotPath).isEmpty()) {
+ throw new IllegalStateException(String.format(
+ "Path Snapshot chain corruption. Error while adding snapshot with " +
+ "snapshotId %s with as the first snapshot in snapshot path: " +
+ "%s which already %d snapshots.", snapshotID, snapshotPath,
+ snapshotChainByPath.get(snapshotPath).size()));
}
if (prevPathID != null && snapshotChainByPath.containsKey(snapshotPath)) {
+ if (snapshotChainByPath.get(snapshotPath).get(prevPathID)
+ .hasNextSnapshotId()) {
+ throw new IllegalStateException(String.format(
+ "Path Snapshot chain corruption. Next snapshotId: %s is already " +
+ "set for snapshotId: %s. Adding snapshot with %s with " +
Review Comment:
```suggestion
"set for snapshotId: %s. Adding snapshotId: %s with " +
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 merged pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 merged PR #5223:
URL: https://github.com/apache/ozone/pull/5223
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] sadanand48 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "sadanand48 (via GitHub)" <gi...@apache.org>.
sadanand48 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1305234372
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +234,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> snapshotChain = new HashMap<>();
Review Comment:
How about using a LinkedList from java.util? We are using the map as linkedlist anyway.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1309096661
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -92,20 +114,38 @@ private void addSnapshotGlobal(UUID snapshotID,
/**
* Add snapshot to bucket snapshot chain(path based).
*/
- private void addSnapshotPath(String snapshotPath,
- UUID snapshotID,
- UUID prevPathID) throws IOException {
+ private void addSnapshotPath(String snapshotPath, UUID snapshotID,
+ UUID prevPathID) {
// On add snapshot, set previous snapshot entry nextSnapshotId = snapshotId
if (prevPathID != null &&
((!snapshotChainByPath.containsKey(snapshotPath)) ||
(!snapshotChainByPath.get(snapshotPath).containsKey(prevPathID)))) {
- throw new IOException(String.format("Snapshot chain corruption. " +
- "Previous snapshotId: %s is set for snapshotId: %s but no " +
- "associated snapshot found in snapshot chain.", prevPathID,
- snapshotID));
+ throw new IllegalStateException(String.format(
+ "Path Snapshot chain corruption. Previous snapshotId: %s is set " +
+ "for snapshotId: %s but no associated snapshot found in " +
+ "snapshot chain.", prevPathID, snapshotID));
+ }
+
+ if (prevPathID == null && snapshotChainByPath.containsKey(snapshotPath) &&
+ !snapshotChainByPath.get(snapshotPath).isEmpty()) {
+ throw new IllegalStateException(String.format(
+ "Path Snapshot chain corruption. Error while adding snapshot with " +
+ "snapshotId %s with as the first snapshot in snapshot path: " +
+ "%s which already %d snapshots.", snapshotID, snapshotPath,
Review Comment:
```suggestion
"%s which already has %d snapshots.", snapshotID, snapshotPath,
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1306009887
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -65,14 +76,15 @@ public void setup() throws Exception {
private SnapshotInfo createSnapshotInfo(UUID snapshotID,
UUID pathPrevID,
- UUID globalPrevID) {
+ UUID globalPrevID,
+ long creationTime) {
return new SnapshotInfo.Builder()
.setSnapshotId(snapshotID)
.setName("test")
.setVolumeName("vol1")
.setBucketName("bucket1")
.setSnapshotStatus(SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)
- .setCreationTime(Time.now())
+ .setCreationTime(creationTime)
Review Comment:
I doubt it is correct to say "this is a negative testcase" because it is in decreasing order now. May be use random number if you really want it to be a true negative test.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1305970863
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +234,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> snapshotChain = new HashMap<>();
Review Comment:
nit: I think variable name and comment are not correct. To me, it is not a chain. It is a map of snapshot to next snapshot. Chain is something in which order is maintained.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1306005063
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -65,14 +76,15 @@ public void setup() throws Exception {
private SnapshotInfo createSnapshotInfo(UUID snapshotID,
UUID pathPrevID,
- UUID globalPrevID) {
+ UUID globalPrevID,
+ long creationTime) {
return new SnapshotInfo.Builder()
.setSnapshotId(snapshotID)
.setName("test")
.setVolumeName("vol1")
.setBucketName("bucket1")
.setSnapshotStatus(SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)
- .setCreationTime(Time.now())
+ .setCreationTime(creationTime)
Review Comment:
Yeah this is a negative testcase which will fail without the change going in.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308058060
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +290,68 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(nodes, Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(nodes, Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(nodes, Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(nodes, Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidGlobalChainFromLoadFromTable(
+ List<UUID> snapshotIDs, Map<UUID, UUID> snapshotChain) throws Exception {
+ Table<String, SnapshotInfo> snapshotInfo =
+ omMetadataManager.getSnapshotInfoTable();
+ for (UUID snapshotID : snapshotIDs) {
+ snapshotInfo.put(snapshotID.toString(),
+ createSnapshotInfo(snapshotID, snapshotChain.get(snapshotID),
+ snapshotChain.get(snapshotID), System.currentTimeMillis()));
+ }
+ Assertions.assertThrows(IllegalStateException.class,
+ () -> new SnapshotChainManager(omMetadataManager));
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(List<UUID> snapshotIDs,
+ Map<UUID, UUID> snapshotChain) throws Exception {
+ Table<String, SnapshotInfo> snapshotInfo =
+ omMetadataManager.getSnapshotInfoTable();
+ UUID prevSnapshotId = null;
+ for (UUID snapshotID : snapshotIDs) {
+ snapshotInfo.put(snapshotID.toString(),
+ createSnapshotInfo(snapshotID, snapshotChain.get(snapshotID),
+ prevSnapshotId, System.currentTimeMillis()));
+ prevSnapshotId = snapshotID;
+ }
+ Assertions.assertThrows(RuntimeException.class,
Review Comment:
Why this is not `IllegalStateException`? I think you can change it to `IllegalStateException` after changing all the exception from `IOException` to `IllegalStateException`.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
+ "the global snapshot chain.", snapshotID,
+ globalSnapshotChain.size()));
+ }
if (prevGlobalID != null && globalSnapshotChain.containsKey(prevGlobalID)) {
Review Comment:
nit: Can we move this `if` block after line 104? Basically move `if` block at line 98-104 before this `if `block
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
Review Comment:
```suggestion
"already present in the chain.", snapshotID));
```
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -105,7 +125,26 @@ private void addSnapshotPath(String snapshotPath,
snapshotID));
}
+ if (prevPathID == null && snapshotChainByPath.containsKey(snapshotPath) &&
+ !snapshotChainByPath.get(snapshotPath).isEmpty()) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Error while adding snapshot with " +
+ "snapshotId %s with as the first snapshot in snapshot path:" +
+ " %s which already %d snapshots.", snapshotID, snapshotPath,
+ snapshotChainByPath.get(snapshotPath).size()));
+ }
+
if (prevPathID != null && snapshotChainByPath.containsKey(snapshotPath)) {
+ if (snapshotChainByPath.get(snapshotPath).get(prevPathID)
+ .getNextSnapshotId() != null) {
+ throw new IOException(String.format("Snapshot chain corruption. " +
Review Comment:
Please use `IllegalStateException`. Also change it for line number 100 and 122 and remove `IOException` from the method signature as well.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
+ "the global snapshot chain.", snapshotID,
+ globalSnapshotChain.size()));
+ }
if (prevGlobalID != null && globalSnapshotChain.containsKey(prevGlobalID)) {
+ if (globalSnapshotChain.get(prevGlobalID).getNextSnapshotId() != null) {
Review Comment:
nit: Should we add `hasNextSnapshotId` and `hasPreviousSnapshotId` in `SnapshotChainInfo`?
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +273,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> nextSnapshotIdMap = new HashMap<>();
Review Comment:
nit: may be `snapshotToNextSnapshotMap`
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -239,8 +253,10 @@ public void testDeleteSnapshot() throws Exception {
assertEquals(snapshotID3, chainManager.previousGlobalSnapshot(snapshotID2));
}
- @Test
- public void testChainFromLoadFromTable() throws Exception {
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testChainFromLoadFromTable(boolean increasingTIme)
Review Comment:
I think it is unnecessary to make it parameterized test. Just use random number generation [here](https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java#L75) because snapshot chain is independent of snapshot creation. It could be increasing, decreasing or mix of both.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
Review Comment:
nit: Can you please change exception message to `Global snapshot chain corruption` for all the exception messages in `addSnapshotGlobal` and `Path level snapshot chain corruption` for the exception messages in `addSnapshotPath`? And assert that exception message starts with correct message in the test.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -105,7 +125,26 @@ private void addSnapshotPath(String snapshotPath,
snapshotID));
}
+ if (prevPathID == null && snapshotChainByPath.containsKey(snapshotPath) &&
+ !snapshotChainByPath.get(snapshotPath).isEmpty()) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Error while adding snapshot with " +
Review Comment:
```suggestion
"Snapshot chain corruption. Error while adding snapshot with " +
"snapshotId: %s as the first snapshot in snapshot path: %s " +
"which already has %d snapshots.", snapshotID, snapshotPath,
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1307748717
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -243,10 +246,37 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
while (keyIter.hasNext()) {
kv = keyIter.next();
- snaps.put(kv.getValue().getCreationTime(), kv.getValue());
+ SnapshotInfo snapshotInfo = kv.getValue();
+ snaps.put(kv.getValue().getSnapshotId(), snapshotInfo);
+ if (snapshotInfo.getGlobalPreviousSnapshotId() != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Global Snapshot chain link {} -> {}",
+ snapshotInfo.getGlobalPreviousSnapshotId(),
+ snapshotInfo.getSnapshotId());
+ }
+ // Adding edge to the linked list. prevGlobalSnapId -> snapId
+ snapshotChain.put(snapshotInfo.getGlobalPreviousSnapshotId(),
+ snapshotInfo.getSnapshotId());
+ } else {
+ head = snapshotInfo.getSnapshotId();
+ }
+ }
+ int size = 0;
+ UUID prev = null;
+ while (head != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Adding Snapshot Info: {}", snaps.get(head));
+ }
+ addSnapshot(snaps.get(head));
+ size += 1;
+ prev = head;
+ head = snapshotChain.get(head);
}
- for (SnapshotInfo snapshotInfo : snaps.values()) {
- addSnapshot(snapshotInfo);
+ if (size != snaps.size()) {
+ throw new IOException(String.format("Snapshot chain corruption. " +
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +234,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> snapshotChain = new HashMap<>();
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +286,56 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(Map<UUID, UUID> snapshotChain)
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] sadanand48 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "sadanand48 (via GitHub)" <gi...@apache.org>.
sadanand48 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1305278525
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +234,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> snapshotChain = new HashMap<>();
Review Comment:
java.util LinkedList doesn't have setnext() ,setPrevious() methods. I guess it's fine to use map in that case.Ignore my comment.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1306024719
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +286,56 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(Map<UUID, UUID> snapshotChain)
Review Comment:
what is the path level previous? Can you elaborate.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on PR #5223:
URL: https://github.com/apache/ozone/pull/5223#issuecomment-1700056286
@hemantk-12 the ci run is succesful. this can be merged
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308034999
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
Review Comment:
This comment doesn't belong here. Please either remove this or move it before line number 85 (may be).
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308284066
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -239,8 +253,10 @@ public void testDeleteSnapshot() throws Exception {
assertEquals(snapshotID3, chainManager.previousGlobalSnapshot(snapshotID2));
}
- @Test
- public void testChainFromLoadFromTable() throws Exception {
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testChainFromLoadFromTable(boolean increasingTIme)
Review Comment:
There are only 2 snapshots we need to test both.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1306149618
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -273,4 +286,56 @@ public void testChainFromLoadFromTable() throws Exception {
() -> chainManager.previousPathSnapshot(String
.join("/", "vol1", "bucket1"), snapshotID1));
}
+
+ private static Stream<? extends Arguments> invalidSnapshotChain() {
+ List<UUID> nodes = IntStream.range(0, 5)
+ .mapToObj(i -> UUID.randomUUID())
+ .collect(Collectors.toList());
+ return Stream.of(
+ Arguments.of(Named.of("Disconnected Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Complete Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(4),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Partial Cyclic Snapshot Chain",
+ ImmutableMap.of(
+ nodes.get(0), nodes.get(3),
+ nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(3)))),
+ Arguments.of(Named.of("Diverged Snapshot Chain",
+ ImmutableMap.of(nodes.get(1), nodes.get(0),
+ nodes.get(2), nodes.get(1),
+ nodes.get(3), nodes.get(2),
+ nodes.get(4), nodes.get(2))))
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidSnapshotChain")
+ public void testInvalidChainFromLoadFromTable(Map<UUID, UUID> snapshotChain)
Review Comment:
[SnapshotChainManager](https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java#L48) maintains two chains. [Global snapshot chain](https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java#L52) and [path level chain](https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java#L53). Path is basically bucket path e.g. `/volume/bucket`.
Your approach should work for both global and path. Test case will just make sure the correctness of 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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1306022418
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -65,14 +76,15 @@ public void setup() throws Exception {
private SnapshotInfo createSnapshotInfo(UUID snapshotID,
UUID pathPrevID,
- UUID globalPrevID) {
+ UUID globalPrevID,
+ long creationTime) {
return new SnapshotInfo.Builder()
.setSnapshotId(snapshotID)
.setName("test")
.setVolumeName("vol1")
.setBucketName("bucket1")
.setSnapshotStatus(SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)
- .setCreationTime(Time.now())
+ .setCreationTime(creationTime)
Review Comment:
Ok yeah that makes sense. Let me do that. I did it for ease.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308035720
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
Review Comment:
nit: `...there are %d snapshots in...` or nodes whatever you feel like.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308339334
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -105,7 +125,26 @@ private void addSnapshotPath(String snapshotPath,
snapshotID));
}
+ if (prevPathID == null && snapshotChainByPath.containsKey(snapshotPath) &&
+ !snapshotChainByPath.get(snapshotPath).isEmpty()) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Error while adding snapshot with " +
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -105,7 +125,26 @@ private void addSnapshotPath(String snapshotPath,
snapshotID));
}
+ if (prevPathID == null && snapshotChainByPath.containsKey(snapshotPath) &&
+ !snapshotChainByPath.get(snapshotPath).isEmpty()) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Error while adding snapshot with " +
+ "snapshotId %s with as the first snapshot in snapshot path:" +
+ " %s which already %d snapshots.", snapshotID, snapshotPath,
+ snapshotChainByPath.get(snapshotPath).size()));
+ }
+
if (prevPathID != null && snapshotChainByPath.containsKey(snapshotPath)) {
+ if (snapshotChainByPath.get(snapshotPath).get(prevPathID)
+ .getNextSnapshotId() != null) {
+ throw new IOException(String.format("Snapshot chain corruption. " +
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1305280955
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -234,7 +234,10 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager) {
// snapshot chains - both global and local path
try (TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
keyIter = metadataManager.getSnapshotInfoTable().iterator()) {
- Map<Long, SnapshotInfo> snaps = new TreeMap<>();
+ Map<UUID, SnapshotInfo> snaps = new HashMap<>();
+ // Forward Linked list for snapshot chain.
+ Map<UUID, UUID> snapshotChain = new HashMap<>();
Review Comment:
java.util.LinkedList search is bad. Since linkBefore function is package private. Only way to add is to use indexes which is bad. We will end up doing a complete iteration in the existing linked list to search for the node O(n^2). This solution when amortized O(n) as hashMap lookup is only O(1).
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308035720
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
Review Comment:
nit: `...there are %d snapshot/s in...` or nodes whatever you feel like.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308034999
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
Review Comment:
This comment doesn't belong here. Please either remove this or move it before line number 85 (may be) or may be use this in java doc what it means.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] hemantk-12 commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1309100997
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -239,8 +253,10 @@ public void testDeleteSnapshot() throws Exception {
assertEquals(snapshotID3, chainManager.previousGlobalSnapshot(snapshotID2));
}
- @Test
- public void testChainFromLoadFromTable() throws Exception {
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testChainFromLoadFromTable(boolean increasingTIme)
Review Comment:
I don't think it is needed. Because randomness will cover both scenarios over the time. Anyways it is upto you.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1307774707
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -65,14 +76,15 @@ public void setup() throws Exception {
private SnapshotInfo createSnapshotInfo(UUID snapshotID,
UUID pathPrevID,
- UUID globalPrevID) {
+ UUID globalPrevID,
+ long creationTime) {
return new SnapshotInfo.Builder()
.setSnapshotId(snapshotID)
.setName("test")
.setVolumeName("vol1")
.setBucketName("bucket1")
.setSnapshotStatus(SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)
- .setCreationTime(Time.now())
+ .setCreationTime(creationTime)
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308284066
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSnapshotChain.java:
##########
@@ -239,8 +253,10 @@ public void testDeleteSnapshot() throws Exception {
assertEquals(snapshotID3, chainManager.previousGlobalSnapshot(snapshotID2));
}
- @Test
- public void testChainFromLoadFromTable() throws Exception {
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testChainFromLoadFromTable(boolean increasingTIme)
Review Comment:
There are only 2 snapshots we need to test both increasing and decreasing creation times.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] swamirishi commented on a diff in pull request #5223: HDDS-9215. Snapshot Chain corruption because snapshot chain need not be created in increasing order of CreatedTime
Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #5223:
URL: https://github.com/apache/ozone/pull/5223#discussion_r1308339025
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
+ "the global snapshot chain.", snapshotID,
+ globalSnapshotChain.size()));
+ }
if (prevGlobalID != null && globalSnapshotChain.containsKey(prevGlobalID)) {
Review Comment:
done
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java:
##########
@@ -71,7 +71,27 @@ public SnapshotChainManager(OMMetadataManager metadataManager) {
private void addSnapshotGlobal(UUID snapshotID,
UUID prevGlobalID) throws IOException {
// On add snapshot, set previous snapshot entry nextSnapshotID = snapshotID
+ if (globalSnapshotChain.containsKey(snapshotID)) {
+ throw new IllegalStateException(String.format(
+ "Snapshot chain corruption. Snapshot with snapshotId: %s is " +
+ "already present in the the chain.", snapshotID));
+ }
+ if (globalSnapshotChain.size() > 0 && prevGlobalID == null) {
+ throw new IllegalStateException(String.format("Snapshot chain " +
+ "corruption. Adding snapshot %s as head node while there are %d in " +
+ "the global snapshot chain.", snapshotID,
+ globalSnapshotChain.size()));
+ }
if (prevGlobalID != null && globalSnapshotChain.containsKey(prevGlobalID)) {
+ if (globalSnapshotChain.get(prevGlobalID).getNextSnapshotId() != null) {
Review Comment:
done
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org