{"record":{"id":"d2288022010d0f6b","repo":"apache/hadoop","slug":"message-currentfilepath","errorCode":null,"errorMessage":"${message}: ${currentFilePath}","messagePattern":"\\$\\{message\\}: \\$\\{currentFilePath\\}","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":908,"sourceCode":"      }\n    }\n  }\n\n  /**\n   * If the sink isn't set to ignore errors, throw a {@link MetricsException}\n   * if the stream encountered an exception.  The message parameter will be used\n   * as the 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   * @throws MetricsException thrown if there was an error and the sink isn't\n   * ignoring errors\n   */\n  private void checkForErrors(String message)\n      throws MetricsException {\n    if (!ignoreError && currentOutStream.checkError()) {\n      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 + \" [\"","sourceCodeStart":890,"sourceCodeEnd":926,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/RollingFileSystemSink.java#L890-L926","documentation":"checkForErrors() polls PrintStream.checkError() because PrintStream silently swallows IOExceptions on write. When the underlying stream to the current metrics file has entered an error state (disk full, HDFS datanode/lease trouble, file removed underneath the sink) and ignore-error is false, it throws MetricsException(\"<message>: <currentFilePath>\"). In this sink the messages used are 'Unable to write to log file' and 'Unable to close log file'.","triggerScenarios":"Local disk (often the default /tmp basepath) filling up; HDFS append failing with too few live datanodes; the current <hostname>.log being deleted or its lease stolen while the sink holds it open.","commonSituations":"Default basepath=/tmp on a small root partition; allow-append=true on an under-replicated cluster; aggressive log cleaners removing sink output files mid-interval.","solutions":["Free disk space or move basepath off /tmp to a managed directory with quota headroom","Check HDFS health — with allow-append=true the docs require ~2-3 live datanodes minimum","Set <prefix>.sink.<instance>.ignore-error=true only if losing metrics is acceptable while you remediate","Inspect logs for the companion messages ('Failed flushing the stream', 'Unable to flush log file') to find the real I/O cause"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"FileStatus st = fileSystem.getFileStatus(basePath);\n// local FS: check usable space\nif (fileSystem instanceof LocalFileSystem) {\n  long usable = new java.io.File(basePath.toUri().getPath()).getUsableSpace();\n  if (usable < 1L << 30) LOG.warn(\"basepath low on space: {} bytes\", usable);\n}","typeGuard":null,"tryCatchPattern":"try {\n  sink.putMetrics(record);\n} catch (MetricsException e) {\n  // '<message>: <currentFilePath>' — PrintStream.checkError() flagged a silent I/O failure\n  // fallback: keep daemon running, note the file, alert ops on storage health\n  LOG.error(\"Metrics file write failed for {} — check disk/HDFS health\",\n      currentFilePath, e);\n}","preventionTips":["Move basepath off /tmp onto monitored storage with capacity alerts","With allow-append=true keep at least 2-3 live datanodes per the sink's documented minimum","Exclude the sink output directories from aggressive external log cleaners","Use ignore-error=true deliberately during known-degraded windows and monitor for it"],"tags":["metrics2","rolling-file-sink","disk-full","write-failure","printstream"],"backgroundTag":"disk-full","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}