apache/druid · warning
Could not close log file for
Error message
Could not close log file for %s. Creating new log file anyway.
What it means
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.
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.
Example fix
// before: log dir on a full/rotated filesystem druid.request.logging.dir=/var/log/druid (disk 100%) // after: monitor/rotate externally and keep space available druid.request.logging.dir=/var/log/druid + logrotate with copytruncate and free-space alerts
Defensive patterns
Strategy: fallback
Try / catch
// FileRequestLogger already suppresses and continues; operators should alert on the log line:
// log.warn("Could not close log file for %s...") and its suppressed exception cause. Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Cannot add files of the same name, already have
- Cannot create directory
- Cannot have a comma in the name of a file, got
- Cannot list directory
- Cannot list directory
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/92997430ddbd86b5.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/server/log/FileRequestLogger.java:128
long nextPeriodMillis = currentPeriodStart.plus(rollPeriod).getMillis();
Duration initialDelay = new Duration(nextPeriodMillis - System.currentTimeMillis());
ScheduledExecutors.scheduleWithFixedDelay(
exec,
initialDelay,
rollPeriod,
new Callable<>()
{
@Override
public ScheduledExecutors.Signal call()
{
try {
synchronized (lock) {
currentPeriodStart = currentPeriodStart.plus(rollPeriod);
CloseableUtils.closeAndSuppressExceptions(
fileWriter,
e -> log.warn("Could not close log file for %s. Creating new log file anyway.", currentPeriodStart)
);
fileWriter = getFileWriter();
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
return ScheduledExecutors.Signal.REPEAT;
}
}
);
if (durationToRetain != null) {
ScheduledExecutors.scheduleWithFixedDelay(
exec,
new Duration(0),
Duration.standardDays(1),View on GitHub (pinned to 9b90983fd2)