HDFS-4739. NN can miscalculate the number of extra edit log segments to retain. Contributed by Aaron T. Myers.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1471773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1efa9d84ab
commit
a0e8dbbb19
|
@ -118,11 +118,17 @@ public class NNStorageRetentionManager {
|
||||||
.result();
|
.result();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove from consideration any edit logs that are in fact required.
|
||||||
|
while (editLogs.size() > 0 &&
|
||||||
|
editLogs.get(editLogs.size() - 1).getFirstTxId() >= minimumRequiredTxId) {
|
||||||
|
editLogs.remove(editLogs.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Next, adjust the number of transactions to retain if doing so would mean
|
// Next, adjust the number of transactions to retain if doing so would mean
|
||||||
// keeping too many segments around.
|
// keeping too many segments around.
|
||||||
while (editLogs.size() > maxExtraEditsSegmentsToRetain) {
|
while (editLogs.size() > maxExtraEditsSegmentsToRetain) {
|
||||||
purgeLogsFrom = editLogs.get(0).getFirstTxId();
|
purgeLogsFrom = editLogs.get(0).getLastTxId() + 1;
|
||||||
editLogs.remove(0);
|
editLogs.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,11 +217,12 @@ public class TestNNStorageRetentionManager {
|
||||||
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(176, 200), true);
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(176, 200), true);
|
||||||
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(201, 225), true);
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(201, 225), true);
|
||||||
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(226, 240), true);
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(226, 240), true);
|
||||||
// Only retain 2 extra segments. The 301-400 segment is considered required,
|
// Only retain 2 extra segments. The 301-350 and 351-400 segments are
|
||||||
// not extra.
|
// considered required, not extra.
|
||||||
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(241, 275), false);
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(241, 275), false);
|
||||||
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(276, 300), false);
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(276, 300), false);
|
||||||
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(301, 400), false);
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(301, 350), false);
|
||||||
|
tc.addLog("/foo2/current/" + getFinalizedEditsFileName(351, 400), false);
|
||||||
tc.addLog("/foo2/current/" + getInProgressEditsFileName(401), false);
|
tc.addLog("/foo2/current/" + getInProgressEditsFileName(401), false);
|
||||||
runTest(tc);
|
runTest(tc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue