HDFS-14048. DFSOutputStream close() throws exception on subsequent call after DataNode restart. Contributed by Erik Krogen.

This commit is contained in:
Inigo Goiri 2018-11-06 11:18:15 -08:00
parent 00a67f770e
commit 887244de4a
2 changed files with 3 additions and 0 deletions

View File

@ -1781,6 +1781,7 @@ boolean createBlockOutputStream(DatanodeInfo[] nodes,
blockStream = out; blockStream = out;
result = true; // success result = true; // success
errorState.resetInternalError(); errorState.resetInternalError();
lastException.clear();
// remove all restarting nodes from failed nodes list // remove all restarting nodes from failed nodes list
failed.removeAll(restartingNodes); failed.removeAll(restartingNodes);
restartingNodes.clear(); restartingNodes.clear();

View File

@ -436,6 +436,8 @@ public Boolean get() {
0, out.getStreamer().getPipelineRecoveryCount()); 0, out.getStreamer().getPipelineRecoveryCount());
out.write(1); out.write(1);
out.close(); out.close();
// Ensure that subsequent closes are idempotent and do not throw errors
out.close();
} finally { } finally {
if (cluster != null) { if (cluster != null) {
cluster.shutdown(); cluster.shutdown();