apache/druid · error · IOException

failed to flush one or more emitters

Error message

failed to flush one or more emitters

What it means

ComposingEmitter.flush() delegates flush to each of its composed child emitters, logging and remembering any child failure. If at least one child emitter failed to flush, it throws IOException 'failed to flush one or more emitters' after attempting all children, so callers know buffered events may not have been delivered.

Source

Thrown at processing/src/main/java/org/apache/druid/java/util/emitter/core/ComposingEmitter.java:79

  @Override
  public void flush() throws IOException
  {
    boolean fail = false;
    log.info("Flushing Composing Emitter.");

    for (Emitter e : emitters) {
      try {
        log.info("Flushing emitter %s.", e.getClass().getName());
        e.flush();
      }
      catch (IOException ex) {
        log.error(ex, "Failed to flush emitter [%s]", e.getClass().getName());
        fail = true;
      }
    }

    if (fail) {
      throw new IOException("failed to flush one or more emitters");
    }
  }

  @Override
  @LifecycleStop
  public void close() throws IOException
  {
    boolean fail = false;
    log.info("Closing Composing Emitter.");

    for (Emitter e : emitters) {
      try {
        log.info("Closing emitter %s.", e.getClass().getName());
        e.close();
      }
      catch (IOException ex) {
        log.error(ex, "Failed to close emitter [%s]", e.getClass().getName());
        fail = true;

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check the logs for 'Failed to flush emitter [...]' entries to identify which child emitter failed
  2. Ensure the backing services/URLs of all child emitters are reachable before flushing
  3. Retry flush() after connectivity is restored, since some children may have succeeded
  4. Wrap flush in try/catch during shutdown to avoid masking the primary shutdown error

Example fix

// before
emitter.flush(); // may throw IOException on shutdown
// after
try {
  emitter.flush();
} catch (IOException e) {
  log.error(e, "Some emitters failed to flush; events may be lost");
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  emitter.flush();
} catch (IOException e) {
  log.error(e, "One or more emitters failed to flush; check child emitter logs");
}

Prevention

When it happens

Trigger: Calling flush() on a ComposingEmitter when any wrapped emitter (e.g. HttpPostEmitter) fails its flush due to I/O errors, closed emitters, or unreachable recipients.

Common situations: Shutdown-time flush when a remote metrics/alert endpoint is down; network partitions during event delivery; child emitter already closed; timeouts on HTTP emitters.

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/5b7354efe9a0473e. Report an issue: GitHub.