Skip to content

Commit

Permalink
HDFS-17454. Fix namenode fsck swallows the exception stacktrace, this…
Browse files Browse the repository at this point in the history
… can help us to troubleshooting log.
  • Loading branch information
xiaojunxiang2023 committed Apr 7, 2024
1 parent 5bfca65 commit 9175c03
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public void fsck() throws AccessControlException {
LOG.warn(errMsg, e);
out.println("FSCK ended at " + new Date() + " in "
+ (Time.monotonicNow() - startTime + " milliseconds"));
out.println(e.getMessage());
e.printStackTrace(out);
out.print("\n\n" + errMsg);
} finally {
out.close();
Expand Down Expand Up @@ -1050,6 +1050,7 @@ private void copyBlocksToLostFound(String parent, HdfsFileStatus file,
} catch (Exception e) {
LOG.error("copyBlocksToLostFound: error processing " + fullName, e);
internalError = true;
throw new IOException(e);
} finally {
if (fos != null) fos.close();
dfs.close();
Expand Down Expand Up @@ -1184,11 +1185,10 @@ private DatanodeInfo bestNode(DFSClient dfs, DatanodeInfo[] nodes,
return chosenNode;
}

private void lostFoundInit(DFSClient dfs) {
private void lostFoundInit(DFSClient dfs) throws IOException {
lfInited = true;
String lfName = "/lost+found";
try {
String lfName = "/lost+found";

final HdfsFileStatus lfStatus = dfs.getFileInfo(lfName);
if (lfStatus == null) { // not exists
lfInitedOk = dfs.mkdirs(lfName, null, true);
Expand All @@ -1201,7 +1201,9 @@ private void lostFoundInit(DFSClient dfs) {
lfInitedOk = true;
}
} catch (Exception e) {
e.printStackTrace();
if (!lfInitedOk) {
throw new IOException("failed to initialize " + lfName, e);
}
lfInitedOk = false;
}
if (lostFound == null) {
Expand Down

0 comments on commit 9175c03

Please sign in to comment.