HDDS-10524. [Snapshot] Invalidate the cache entry from snapshotInfoTable cache in OMSnapshotPurgeRequest #6443
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Currently when snapshot is purged, it is not removed from the snapshotInfoTable cache. Because of which it is possible that a purged snapshot is added by
SnapshotSetPropertyAPI.KeyDeletingServiceandSnapshotDeletingServiceare two background service which run in parallel.1). KeyDeletingService updates deep clean flag and exclusive size for a snapshot.
2). SnapshotDeletingService purges a deleted snapshot.
KeyDeletionService will try to mark a snapshot deep clean here: code
Since it is in a loop, it is possible when KeyDeletingService is going over all the snapshot. Meanwhile user deletes the snapshot, SnapshotDeletingService kicks in and purge the snapshot code here.
Now when
OMSnapshotSetPropertyRequestgets request to update deep clean for the same snapshot (purged by SnapshotDeletingService), it gets the value from cache because we don’t purge snapshot from cache on the purge path and wait for double buffer flush.Now there are two transaction in double buffer one for purge and other for updating deep clean. Some time snapshot can be present in the cache and sometime it doesn’t. When it has snapshot in cache, it causes snapshot chain corruption because both of the transaction will succeed.
In this change, we are invalidating the cache entry in
OMSnapshotPurgeRequestso that other APIs don't see the snapshot.What is the link to the Apache JIRA
HDDS-10524
How was this patch tested?
Wrote a test to mimic the same behavior as in described in the details. This test was run against existing code and with fix. It failed all the time in the existing code and passed in fixed code.
Also updated existing unit test to validate before and after snapshot purge transaction is committed.