HDFS-17045. File renamed from a snapshottable dir to a non-snapshottable dir cannot be deleted. (#5738)
This commit is contained in:
parent
1a918a6b96
commit
5dd37b2814
@ -831,17 +831,17 @@ public void cleanSubtree(ReclaimContext reclaimContext, int snapshot,
|
|||||||
*
|
*
|
||||||
* @param context to {@link ReclaimContext#getSnapshotIdToBeDeleted()}
|
* @param context to {@link ReclaimContext#getSnapshotIdToBeDeleted()}
|
||||||
*/
|
*/
|
||||||
private boolean shouldDestroy(ReclaimContext context) {
|
private void shouldDestroy(ReclaimContext context) {
|
||||||
final int snapshotToBeDeleted = context.getSnapshotIdToBeDeleted();
|
final int snapshotToBeDeleted = context.getSnapshotIdToBeDeleted();
|
||||||
if (dstSnapshotId < snapshotToBeDeleted) {
|
if (snapshotToBeDeleted == Snapshot.CURRENT_STATE_ID
|
||||||
return true;
|
|| snapshotToBeDeleted > dstSnapshotId) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
LOG.warn("Try to destroy a DstReference with dstSnapshotId = {}"
|
LOG.warn("Try to destroy a DstReference with dstSnapshotId = {}"
|
||||||
+ " >= snapshotToBeDeleted = {}", dstSnapshotId, snapshotToBeDeleted);
|
+ " >= snapshotToBeDeleted = {}", dstSnapshotId, snapshotToBeDeleted);
|
||||||
LOG.warn(" dstRef: {}", toDetailString());
|
LOG.warn(" dstRef: {}", toDetailString());
|
||||||
final INode r = getReferredINode().asReference().getReferredINode();
|
final INode r = getReferredINode().asReference().getReferredINode();
|
||||||
LOG.warn(" referred: {}", r.toDetailString());
|
LOG.warn(" referred: {}", r.toDetailString());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -857,9 +857,7 @@ private boolean shouldDestroy(ReclaimContext context) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void destroyAndCollectBlocks(ReclaimContext reclaimContext) {
|
public void destroyAndCollectBlocks(ReclaimContext reclaimContext) {
|
||||||
if (!shouldDestroy(reclaimContext)) {
|
shouldDestroy(reclaimContext);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// since we count everything of the subtree for the quota usage of a
|
// since we count everything of the subtree for the quota usage of a
|
||||||
// dst reference node, here we should just simply do a quota computation.
|
// dst reference node, here we should just simply do a quota computation.
|
||||||
|
@ -163,6 +163,7 @@ public void testRenameFromSDir2NonSDir() throws Exception {
|
|||||||
|
|
||||||
hdfs.delete(bar, false);
|
hdfs.delete(bar, false);
|
||||||
Assert.assertEquals(1, withCount.getReferenceCount());
|
Assert.assertEquals(1, withCount.getReferenceCount());
|
||||||
|
restartClusterAndCheckImage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean existsInDiffReport(List<DiffReportEntry> entries,
|
private static boolean existsInDiffReport(List<DiffReportEntry> entries,
|
||||||
@ -196,6 +197,7 @@ public void testRenameFileNotInSnapshot() throws Exception {
|
|||||||
assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
|
assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
|
||||||
assertTrue(existsInDiffReport(entries, DiffType.CREATE, file2.getName(),
|
assertTrue(existsInDiffReport(entries, DiffType.CREATE, file2.getName(),
|
||||||
null));
|
null));
|
||||||
|
restartClusterAndCheckImage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,6 +220,7 @@ public void testRenameFileInSnapshot() throws Exception {
|
|||||||
assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
|
assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
|
||||||
assertTrue(existsInDiffReport(entries, DiffType.RENAME, file1.getName(),
|
assertTrue(existsInDiffReport(entries, DiffType.RENAME, file1.getName(),
|
||||||
file2.getName()));
|
file2.getName()));
|
||||||
|
restartClusterAndCheckImage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test (timeout=60000)
|
@Test (timeout=60000)
|
||||||
|
Loading…
Reference in New Issue
Block a user