-
Notifications
You must be signed in to change notification settings - Fork 589
HDDS-9636. Fix NoSuchElement in OMSnapshotPurgeRequest and exit loop early in SnapshotDeletingService #5554
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.NoSuchElementException; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
|
|
@@ -143,23 +144,33 @@ public static void checkSnapshotActive(SnapshotInfo snapInfo, | |
| public static SnapshotInfo getNextActiveSnapshot(SnapshotInfo snapInfo, | ||
| SnapshotChainManager chainManager, OmSnapshotManager omSnapshotManager) | ||
| throws IOException { | ||
| while (chainManager.hasNextPathSnapshot(snapInfo.getSnapshotPath(), | ||
| snapInfo.getSnapshotId())) { | ||
|
|
||
| UUID nextPathSnapshot = | ||
| chainManager.nextPathSnapshot( | ||
| snapInfo.getSnapshotPath(), snapInfo.getSnapshotId()); | ||
| // If the snapshot is deleted in the previous run, then the in-memory | ||
| // SnapshotChainManager might throw NoSuchElementException as the snapshot | ||
| // is removed in-memory but OMDoubleBuffer has not flushed yet. | ||
| try { | ||
| while (chainManager.hasNextPathSnapshot(snapInfo.getSnapshotPath(), | ||
| snapInfo.getSnapshotId())) { | ||
|
|
||
| String tableKey = chainManager.getTableKey(nextPathSnapshot); | ||
| SnapshotInfo nextSnapshotInfo = | ||
| omSnapshotManager.getSnapshotInfo(tableKey); | ||
| UUID nextPathSnapshot = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aswinshakil When would getNextActiveSnapshot be called and the current snapshot also deleted in parallel. I guess this should not happen right?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is called when the current snapshot is deleted. This is to set the deep clean flag.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are deleting the current snapshot from the chain then why call this function at the first place, it would return null anyhow right? So do you mean to say we are deleting snapshots which are not deep cleaned? So are we not taking any lock on the portion of the chain.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #5339, |
||
| chainManager.nextPathSnapshot( | ||
| snapInfo.getSnapshotPath(), snapInfo.getSnapshotId()); | ||
|
|
||
| if (nextSnapshotInfo.getSnapshotStatus().equals( | ||
| SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)) { | ||
| return nextSnapshotInfo; | ||
| } | ||
| String tableKey = chainManager.getTableKey(nextPathSnapshot); | ||
| SnapshotInfo nextSnapshotInfo = | ||
| omSnapshotManager.getSnapshotInfo(tableKey); | ||
|
|
||
| snapInfo = nextSnapshotInfo; | ||
| if (nextSnapshotInfo.getSnapshotStatus().equals( | ||
| SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE)) { | ||
| return nextSnapshotInfo; | ||
| } | ||
|
|
||
| snapInfo = nextSnapshotInfo; | ||
| } | ||
| } catch (NoSuchElementException ex) { | ||
| LOG.error("The snapshot {} is not longer in snapshot chain, It " + | ||
| "maybe removed in the previous Snapshot purge request.", | ||
| snapInfo.getTableKey()); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Table#iterator(prefix)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware this existed. Yes, we can do it, but we need to change this in multiple places and test it. I can do it as a part of a larger separate patch.