Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-10010. Support snapshot rename operation #6006

Merged
merged 7 commits into from
Feb 20, 2024

Conversation

Cyrill
Copy link
Contributor

@Cyrill Cyrill commented Jan 15, 2024

What changes were proposed in this pull request?

HDDS-10010. Support snapshot rename operation

Ozone implements org.apache.hadoop.fs.FileSystem, which has three methods to work with snapshots - create, rename and delete. Only create and delete are implemented at the moment.
Implementing snapshot rename will improve Ozone compatibility with other software (that uses snapshots functionality).

What is the link to the Apache JIRA

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

How was this patch tested?

Tested with unit tests an manual testing.

@adoroszlai adoroszlai added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Jan 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 for the patch @Cyrill.
I looked at briefly and the only two major concerns I've are

  1. Snapshot chain manager needs to be updated.
  2. SnapshotCache: currently snapshotCache used /volName/bucketName/snapshotName as key for the cache. When we do a rename, we may need to update the cache as well. Or we can think if we should use snapshotId for it.

Afair, SnapshotDiff uses SnapshotId and snapshot rename should not be a problem there but it would be great if you can double check that part as well.

@Cyrill Cyrill requested a review from hemantk-12 January 18, 2024 10:22
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.

My main concern with snapshot renaming is SnapshotCache. Currently SnapshotName is used as key in SnapshotCache.

Invalidating cache for snapshot rename doesn't make sense to me. Invalidate should only be used when snapshot is purged. Also invalidating cache for active snapshot will impact background service (KeyDeletingService, SSTFilteringService, SnapshotDeletingService, and SnapDiff).

To me better approach would be to use SnapshotId as key in SnapshotCache. This change could be a follow up task. I'm to other suggestion as well.


updateSnapshotInChainManager(omMetadataManager, snapshotOldInfo);

ozoneManager.getOmSnapshotManager().getSnapshotCache().invalidate(snapshotOldTableKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I don't think it is good idea to invalidate the cache because of snapshot rename. I guess better approach would be to use snapshotId as key for snapshotCache.
  2. Unit test is failing due to NPE in this line. Please take a look of that.
Error:  Tests run: 13, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.973 s <<< FAILURE! -- in org.apache.hadoop.ozone.om.request.snapshot.TestOMSnapshotRenameRequest
Error:  org.apache.hadoop.ozone.om.request.snapshot.TestOMSnapshotRenameRequest.testValidateAndUpdateCache -- Time elapsed: 0.178 s <<< ERROR!
java.lang.NullPointerException
	at org.apache.hadoop.ozone.om.request.snapshot.OMSnapshotRenameRequest.validateAndUpdateCache(OMSnapshotRenameRequest.java:192)
	at org.apache.hadoop.ozone.om.request.OMClientRequest.validateAndUpdateCache(OMClientRequest.java:145)
	at org.apache.hadoop.ozone.om.request.snapshot.TestOMSnapshotRenameRequest.testValidateAndUpdateCache(TestOMSnapshotRenameRequest.java:217)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Removed the cache invalidate call here

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.

I took a quick look at the patch. My main concern is similar to what @hemantk-12 suggested, There is KeyDeletingService, SnapshotDirectoryCleanupService and the OM requests used by this services pass the snapshot name in the request to OM to identify the snapshot. If a rename happened in between these requests this may cause undefined behaviour.

I would suggest changing these other classes as well to use snapshotId instead of snapshot name is the way to go forward.

@Cyrill
Copy link
Contributor Author

Cyrill commented Feb 14, 2024

Hi @hemantk-12, are there any more changes required for this PR to move forward?

@Cyrill Cyrill requested a review from hemantk-12 February 14, 2024 08:19
@Cyrill
Copy link
Contributor Author

Cyrill commented Feb 20, 2024

@hemantk-12 @aswinshakil Is there any chance to help me with moving this PR forward?

@hemantk-12 hemantk-12 merged commit a1f8390 into apache:master Feb 20, 2024
35 checks passed
@hemantk-12
Copy link
Contributor

@Cyrill I was busy with other stuff last week and didn't get chance to look into this.

LGTM.

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.

4 participants