{"record":{"id":"6ba05647cb1cb23e","repo":"apache/hadoop","slug":"message-currentfilepath-t","errorCode":null,"errorMessage":"${message}: ${currentFilePath} [${t}]","messagePattern":"\\$\\{message\\}: \\$\\{currentFilePath\\} \\[\\$\\{t\\}\\]","errorType":"exception","errorClass":"MetricsException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/RollingFileSystemSink.java","lineNumber":926,"sourceCode":"      throw new MetricsException(message + \": \" + currentFilePath);\n    }\n  }\n\n  /**\n   * If the sink isn't set to ignore errors, wrap the Throwable in a\n   * {@link MetricsException} and throw it.  The message parameter will be used\n   * as the new exception's message with the current file name\n   * ({@link #currentFilePath}) and the Throwable's string representation\n   * appended to it.\n   *\n   * @param message the exception message. The message will have a colon, the\n   * current file name ({@link #currentFilePath}), and the Throwable's string\n   * representation (wrapped in square brackets) appended to it.\n   * @param t the Throwable to wrap\n   */\n  private void throwMetricsException(String message, Throwable t) {\n    if (!ignoreError) {\n      throw new MetricsException(message + \": \" + currentFilePath + \" [\"\n          + t.toString() + \"]\", t);\n    }\n  }\n\n  /**\n   * If the sink isn't set to ignore errors, throw a new\n   * {@link MetricsException}.  The message parameter will be used  as the\n   * new exception's message with the current file name\n   * ({@link #currentFilePath}) appended to it.\n   *\n   * @param message the exception message. The message will have a colon and\n   * the current file name ({@link #currentFilePath}) appended to it.\n   */\n  private void throwMetricsException(String message) {\n    if (!ignoreError) {\n      throw new MetricsException(message + \": \" + currentFilePath);\n    }\n  }","sourceCodeStart":908,"sourceCodeEnd":944,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/RollingFileSystemSink.java#L908-L944","documentation":"throwMetricsException(message, t) wraps a Throwable — practically always an IOException — caught while the sink operates on the current metrics file, and rethrows it as MetricsException with the message, current file path and cause string appended: \"<message>: <currentFilePath> [<t>]\". Its call sites in this sink are 'Failed to create new log file' (rolling to a new file), 'Failed flushing the stream' and 'Unable to flush log file' (hsync/hflush). It is suppressed entirely when ignore-error is true.","triggerScenarios":"FileSystem.create/append failing at roll time (permissions, NameNode issues); hsync/hflush IOException from HDFS lease recovery or datanode failures; allow-append=true with fewer than the minimum live datanodes.","commonSituations":"The interval roll coinciding with HDFS maintenance or an unhealthy cluster; the current file's lease being stolen by another process; safe mode during a roll.","solutions":["Read the bracketed cause in the message — it names the actual HDFS IOException (lease, datanode, safe mode)","Restore HDFS health; verify at least 2-3 live datanodes when using allow-append=true","Consider allow-append=false so the sink writes a new suffixed file each roll instead of appending","Set ignore-error=true to keep the daemon metrics pipeline alive at the cost of dropped data while diagnosing"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// before enabling append mode, confirm HDFS supports it and has datanodes\nif (allowAppend && !fileSystem.append(new Path(basePath, \"probe\")).isPresent()) {\n  LOG.warn(\"Target filesystem may not support append; prefer allow-append=false\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  sink.flush();\n} catch (MetricsException e) {\n  // '<message>: <file> [<cause>]' — the bracketed cause is the real HDFS IOException\n  // fallback: log, keep daemon alive, rely on next roll opening a fresh file\n  LOG.error(\"Metrics file flush failed ({}): {}\", currentFilePath, e.getCause(), e);\n}","preventionTips":["Keep HDFS healthy around roll boundaries — schedule NameNode maintenance away from interval starts","Use allow-append=false when cluster health is marginal; new-file mode avoids lease/append pitfalls","Alert on 'Failed to create new log file' / 'Failed flushing the stream' — they precede data loss","Consider ignore-error=true only as an explicit degradation tradeoff"],"tags":["metrics2","rolling-file-sink","hdfs","io","append"],"backgroundTag":"hdfs-write-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}