apache/druid · info

Failed to close OpenLineage HTTP client

Error message

Failed to close OpenLineage HTTP client

What it means

When the OpenLineage request logger stops, it shuts down its worker executor and then closes the underlying HTTP client. If closing the client throws, the warning 'Failed to close OpenLineage HTTP client' is logged (exception suppressed) so shutdown still completes.

Source

Thrown at extensions-contrib/openlineage-emitter/src/main/java/org/apache/druid/extensions/openlineage/OpenLineageRequestLogger.java:199

  @Override
  public void stop()
  {
    if (emitExecutor != null) {
      emitExecutor.shutdown();
      try {
        if (!emitExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
          emitExecutor.shutdownNow();
        }
      }
      catch (InterruptedException e) {
        emitExecutor.shutdownNow();
        Thread.currentThread().interrupt();
      }
    }
    if (httpClient instanceof Closeable) {
      CloseableUtils.closeAndSuppressExceptions(
          (Closeable) httpClient,
          e -> log.warn(e, "Failed to close OpenLineage HTTP client")
      );
    }
    log.info("Stopped OpenLineage request logger");
  }

  @Override
  public void logNativeQuery(RequestLogLine requestLogLine) throws IOException
  {
    if (requestLogLine.getQuery() == null) {
      return;
    }

    String queryType = requestLogLine.getQuery().getType();

    if (excludedNativeQueryTypes.contains(queryType)) {
      return;
    }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check for double-stop: ensure stop() is called only once in the service lifecycle
  2. Make sure emit workers are drained/interrupted before close (executor shutdown + awaitTermination) precedes the client close
  3. If persistent, upgrade the HTTP client library; this is usually benign and suppressed anyway
  4. Verify no custom httpClient is shared with other components that close it first

Example fix

// before
openLineageRequestLogger.stop();
openLineageRequestLogger.stop(); // second close fails
// after
if (!stopped) {
  openLineageRequestLogger.stop();
  stopped = true;
}
Defensive patterns

Strategy: try-catch

Try / catch

try { logger.stop(); } catch (RuntimeException e) { log.warn("Suppress during shutdown", e); }

Prevention

When it happens

Trigger: Calling stop() while the OkHttp/Closeable HTTP client's connection pool or dispatcher cannot shut down cleanly — typically leaked connections, in-flight requests, or an already-closed client being closed twice.

Common situations: Stopping Druid during shutdown while OpenLineage POSTs are still in flight; calling stop() twice on the same logger; network stack issues keeping sockets open during close.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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