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

HDFS-15201 SnapshotCounter hits MaxSnapshotID limit #1870

Merged
merged 5 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class SnapshotManager implements SnapshotStatsMXBean {
private final boolean snapshotDiffAllowSnapRootDescendant;

private final AtomicInteger numSnapshots = new AtomicInteger();
private static final int SNAPSHOT_ID_BIT_WIDTH = 24;
private static final int SNAPSHOT_ID_BIT_WIDTH = 28;

private boolean allowNestedSnapshots = false;
private int snapshotCounter = 0;
Expand Down Expand Up @@ -541,8 +541,8 @@ public void clearSnapshottableDirs() {
*
* @return maximum allowable snapshot ID.
*/
public int getMaxSnapshotID() {
return ((1 << SNAPSHOT_ID_BIT_WIDTH) - 1);
public int getMaxSnapshotID() {
return ((1 << SNAPSHOT_ID_BIT_WIDTH) - 2);
}

private ObjectName mxBeanName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,18 @@ public void testSnapshotLimits() throws Exception {
StringUtils.toLowerCase(se.getMessage()).contains("rollover"));
}
}

/**
* Snapshot is identified by INODE CURRENT_STATE_ID.
* So maximum allowable snapshotID should be less than CURRENT_STATE_ID
*/
@Test
public void testValidateSnapshotIDWidth() {
FSDirectory fsdir = mock(FSDirectory.class);
SnapshotManager snapshotManager = new SnapshotManager(new Configuration(),
fsdir);
Assert.assertTrue(snapshotManager.
karthikhw marked this conversation as resolved.
Show resolved Hide resolved
getMaxSnapshotID() < Snapshot.CURRENT_STATE_ID);
}

}