{"record":{"id":"92997430ddbd86b5","repo":"apache/druid","slug":"could-not-close-log-file-for-s-creating-new-log","errorCode":null,"errorMessage":"Could not close log file for %s. Creating new log file anyway.","messagePattern":"Could not close log file for (.+?)\\. Creating new log file anyway\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/server/log/FileRequestLogger.java","lineNumber":128,"sourceCode":"      long nextPeriodMillis = currentPeriodStart.plus(rollPeriod).getMillis();\n      Duration initialDelay = new Duration(nextPeriodMillis - System.currentTimeMillis());\n\n      ScheduledExecutors.scheduleWithFixedDelay(\n          exec,\n          initialDelay,\n          rollPeriod,\n          new Callable<>()\n          {\n            @Override\n            public ScheduledExecutors.Signal call()\n            {\n              try {\n                synchronized (lock) {\n                  currentPeriodStart = currentPeriodStart.plus(rollPeriod);\n\n                  CloseableUtils.closeAndSuppressExceptions(\n                      fileWriter,\n                      e -> log.warn(\"Could not close log file for %s. Creating new log file anyway.\", currentPeriodStart)\n                  );\n\n                  fileWriter = getFileWriter();\n                }\n              }\n              catch (Exception e) {\n                throw new RuntimeException(e);\n              }\n\n              return ScheduledExecutors.Signal.REPEAT;\n            }\n          }\n      );\n      if (durationToRetain != null) {\n        ScheduledExecutors.scheduleWithFixedDelay(\n            exec,\n            new Duration(0),\n            Duration.standardDays(1),","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/server/log/FileRequestLogger.java#L110-L146","documentation":"FileRequestLogger rolls its request-log file each period. When closing the previous period's writer throws, CloseableUtils.closeAndSuppressExceptions logs this warning and the logger proceeds to open a new log file anyway. Data meant for the old writer may be lost, but request logging continues.","triggerScenarios":"The scheduled roll task in FileRequestLogger.call() advances currentPeriodStart and calls CloseableUtils.closeAndSuppressExceptions(fileWriter, ...); the underlying writer's close() throws (disk full, filesystem error, stream already closed).","commonSituations":"Disk full or I/O errors on the log directory; log volume unmounted or read-only while rolling; concurrent external rotation of the same file.","solutions":["Inspect the suppressed exception logged alongside this message for the root I/O cause.","Free disk space or fix permissions on the directory configured by druid.request.logging.dir.","Ensure the log directory is on a mounted, writable volume for the Druid process user.","If it recurs, restart the node to reopen a clean writer and confirm no other process owns the log file."],"exampleFix":"// before: log dir on a full/rotated filesystem\ndruid.request.logging.dir=/var/log/druid (disk 100%)\n// after: monitor/rotate externally and keep space available\ndruid.request.logging.dir=/var/log/druid  + logrotate with copytruncate and free-space alerts","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// FileRequestLogger already suppresses and continues; operators should alert on the log line:\n// log.warn(\"Could not close log file for %s...\") and its suppressed exception cause.","preventionTips":["Monitor free disk space on the request-log directory.","Do not rotate the file with external tools while Druid holds the writer.","Ensure the log directory is writable and mounted at all times.","Restart the node if roll failures recur to reopen a clean writer."],"tags":["logging","io","file","rotation"],"backgroundTag":"file-write-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}