HDFS-8384. Allow NN to startup if there are files having a lease but are not under construction. Contributed by Jing Zhao.

(cherry picked from commit 8928729c80)
This commit is contained in:
Jing Zhao 2015-09-04 11:42:22 -07:00
parent 8f712dd2f0
commit 21178f0b1b
3 changed files with 12 additions and 2 deletions

View File

@ -546,6 +546,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9012. Move o.a.h.hdfs.protocol.datatransfer.PipelineAck class to HDFS-9012. Move o.a.h.hdfs.protocol.datatransfer.PipelineAck class to
hadoop-hdfs-client module. (Mingliang Liu via wheat9) hadoop-hdfs-client module. (Mingliang Liu via wheat9)
HDFS-8384. Allow NN to startup if there are files having a lease but are not
under construction. (jing9)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

View File

@ -3181,7 +3181,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
assert hasWriteLock(); assert hasWriteLock();
FileUnderConstructionFeature uc = pendingFile.getFileUnderConstructionFeature(); FileUnderConstructionFeature uc = pendingFile.getFileUnderConstructionFeature();
Preconditions.checkArgument(uc != null); if (uc == null) {
throw new IOException("Cannot finalize file " + src
+ " because it is not under construction");
}
leaseManager.removeLease(uc.getClientName(), pendingFile); leaseManager.removeLease(uc.getClientName(), pendingFile);
pendingFile.recordModification(latestSnapshot); pendingFile.recordModification(latestSnapshot);

View File

@ -108,7 +108,11 @@ public class LeaseManager {
long numUCBlocks = 0; long numUCBlocks = 0;
for (Long id : getINodeIdWithLeases()) { for (Long id : getINodeIdWithLeases()) {
final INodeFile cons = fsnamesystem.getFSDirectory().getInode(id).asFile(); final INodeFile cons = fsnamesystem.getFSDirectory().getInode(id).asFile();
Preconditions.checkState(cons.isUnderConstruction()); if (!cons.isUnderConstruction()) {
LOG.warn("The file " + cons.getFullPathName()
+ " is not under construction but has lease.");
continue;
}
BlockInfo[] blocks = cons.getBlocks(); BlockInfo[] blocks = cons.getBlocks();
if(blocks == null) { if(blocks == null) {
continue; continue;