Skip to content

Conversation

@swamirishi
Copy link
Contributor

What changes were proposed in this pull request?

On snapshot deletes, not all rename table entries are propogated to the next snapshot. This could lead to an incorrect reclamation of blocks on certain edge case scenarios.

Snapshot deletion steps:

  1. Has the snapshot been flushed to disk
  2. If next snapshot is not in deleted state
  3. If the next snapshot is AOS, then check key deletion service is not running
  4. Move all renameTableEntries/deleted/deletedDirectoryTable keys to next snapshot/AOS
  5. Check all tables empty
  6. Purge snapshot from the chain.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11408

How was this patch tested?

Adding unit tests

…on snapshot deletes

Change-Id: I79bcf24d6517bd740aae0c7cf9915146b34d0931
@adoroszlai adoroszlai added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Sep 15, 2024
Copy link
Contributor

@hemantk-12 hemantk-12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @swamirishi for working on this.

I'm half done with the review and leaving some comments.

int currentCount = 0;
while (renamedKeyIter.hasNext() && currentCount < count) {
Table.KeyValue<String, String> kv = renamedKeyIter.next();
if (kv != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be null? hasNext() should do this check?

Change-Id: Ib9e08a7bdf603a4a26e7631c7b5a978d89c32a5a
Change-Id: Ifc9b97ffb05aa079bec5de9b08739c662d18c9ec
Copy link
Member

@aswinshakil aswinshakil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on the patch @swamirishi. I'm posting my comments halfway through the code, I have yet to review the core logic.

Change-Id: I7b5d16029296b45fe49709121b0608c37ccc634b
Change-Id: Id6ce92feed88029bfbea9fdcdb77e123d097519f
Change-Id: I501790e90bd6005dde625f286db3969dbf0c99aa
@hemantk-12 hemantk-12 changed the title HDDS-11408. Snapshot rename table entries are propogated incorrectly on snapshot deletes HDDS-11408. Snapshot rename table entries are propagated incorrectly on snapshot deletes Sep 16, 2024
Change-Id: Idd1c12d2a457ff024f798df4833deeb9fb73f4eb
Change-Id: I4503a43edef21e0511e5d9517217ff7fd9ee6a0b
Change-Id: I746be2343c3aa075ae8470a2b58587bab6c72f89
Change-Id: I3353211ab7269cc4506489019a6c2992554da658
Change-Id: I485ed971c9f9cb2240cfc807ff29188c9ba90f7e
Change-Id: If9552a29f9a6b78ee828841b113d015f6f51199d
Change-Id: I7f76fdd5b7c8fc8b9477ff1cd96dd4eefdc47d20
Change-Id: I12c2ce8da14fd8d30c78953be06efd96429ed190
Change-Id: I43a67c1ae02d9a89391aa48dfec0238debb1c5c5
Change-Id: I0aa53260461fe306cb3b9c95fe0366d7764d6531
Change-Id: Iedfa1dbc2294ffcb486a941599a73bc0e35acf44
Change-Id: Iffea07415eea4c5a071264f66516b8f041cce290
Change-Id: I0fb68ee048e9b85ce412b10b8791ca4bfe74d3aa
Change-Id: Ia6efe2b4ef67e1b4bd847cd1a3301b3ffbe585d0
Change-Id: I9c7d92c66fad94166e6b5da5973a404e4fca1c58
om.getKeyManager().getDeletedDirEntries(testBucket.getVolumeName(),
testBucket.getName(), 1000);
renamesKeyEntries.forEach(entry -> Assertions.assertTrue(aosRenamesKeyEntries.contains(entry)));
deletedKeyEntries.forEach(entry -> Assertions.assertTrue(aosDeletedKeyEntries.contains(entry)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also assert that these keys are removed from the snapshot to be deleted ?

Comment on lines +359 to +375
@Override
public boolean equals(Object obj) {
if (!(obj instanceof KeyValue)) {
return false;
}
KeyValue<?, ?> kv = (KeyValue<?, ?>) obj;
try {
return getKey().equals(kv.getKey()) && getValue().equals(kv.getValue());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Override
public int hashCode() {
return Objects.hash(getKey(), getValue());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: Is this for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swamirishi , This seems incorrect. Filed HDDS-13235

BTW, testing code should reside in tests. Otherwise, it may introduce real bugs to production code.

* underlying metadataManager.
* @throws IOException
*/
List<Table.KeyValue<String, String>> getRenamesKeyEntries(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not asking to create another map. I'm saying the return type could be a map rather than a list of pairs.

int currentCount = 0;
while (tableIterator.hasNext() && currentCount < count) {
Table.KeyValue<String, V> kv = tableIterator.next();
if (kv != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is no harm but it isn't how an iterator is supposed to be used unless null is allowed value in the collection.

List<SnapshotMoveKeyInfos> deletedDirs = new ArrayList<>(moveTableKeysRequest.getDeletedDirsList().size());
//validate deleted key starts with bucket FSO path prefix.[/<volId>/<bucketId>/]
for (SnapshotMoveKeyInfos deletedDir : moveTableKeysRequest.getDeletedDirsList()) {
// Filter deleted directories with exactly one keyInfo per key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it the same as line 120?

Change-Id: Ia56d8cd8c11ab74fd9f9076516d939bcc88f3559
@swamirishi swamirishi marked this pull request as ready for review September 20, 2024 04:08
Copy link
Contributor

@hemantk-12 hemantk-12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @swamirishi for finding this critical issue and fixing it.

LGTM+1.

Change-Id: Ia69b99aef696fa20f299670b1fdcc3f790ca8e19
@swamirishi swamirishi merged commit 8c0b54e into apache:master Sep 20, 2024
@swamirishi
Copy link
Contributor Author

Thank you for the reviews on the patch @aswinshakil @hemantk-12 @prashantpogde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot https://issues.apache.org/jira/browse/HDDS-6517

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants