apache/druid · warning
Background lookup manager thread could not be cancelled
Error message
Background lookup manager thread could not be cancelled
What it means
LookupCoordinatorManager.stop() attempts to cancel the background lookup management loop via backgroundManagerFuture.cancel(true). If the future cannot be cancelled (already completed normally or cancellation was rejected), a warning is logged. This is not an exception; it is a diagnostic that the background thread shut down by its own means instead of being interrupted.
Solutions
- Verify the background task is not exiting prematurely; check for exceptions swallowed in lookupManagementLoop.
- If expected during shutdown, treat this log as informational; no action needed.
- Check executorService shutdown logic in stop()/start() to ensure futures are recreated on restart.
Example fix
// before
if (backgroundManagerFuture != null && !backgroundManagerFuture.cancel(true)) {
LOG.warn("Background lookup manager thread could not be cancelled");
}
// after
if (backgroundManagerFuture != null && !backgroundManagerFuture.isDone() && !backgroundManagerFuture.cancel(true)) {
LOG.warn("Background lookup manager thread could not be cancelled");
} Defensive patterns
Strategy: try-catch
Try / catch
// treat as informational
if (backgroundManagerFuture != null && !backgroundManagerFuture.isDone()) {
boolean cancelled = backgroundManagerFuture.cancel(true);
LOG.debug("cancelled=%s", cancelled);
} Prevention
- Check isDone() before cancel to distinguish natural completion from failed cancellation
- Ensure start()/stop() pairs are balanced under leader handoff
- Log at debug in expected shutdown paths
When it happens
Trigger: Calling stop() when the background management loop has already finished executing (future completed), or when the scheduled task rejected cancellation.
Common situations: Race where the loop exits on its own while stop() runs; repeated start/stop cycles in tests or leader handoff; coordinator losing and regaining leadership quickly.
Related errors
- Already shut down, not starting again
- Attempt to add row to swapped-out sink for segment
- can't start.
- can't stop.
- can't stop.
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/b751968f501106bf.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/server/lookup/cache/LookupCoordinatorManager.java:464
//so that subsequent stop() would happen, even if start() failed with exception
lifecycleLock.started();
lifecycleLock.exitStart();
}
}
}
public void stop()
{
synchronized (lifecycleLock) {
if (!lifecycleLock.canStop()) {
throw new ISE("LookupCoordinatorManager can't stop.");
}
try {
LOG.debug("Stopping");
if (backgroundManagerFuture != null && !backgroundManagerFuture.cancel(true)) {
LOG.warn("Background lookup manager thread could not be cancelled");
}
// signal the executorService to shut down ASAP, if this coordinator becomes leader again
// then start() would ensure that this executorService is finished before starting a
// new one.
if (executorService != null) {
executorService.shutdownNow();
}
LOG.debug("Stopped");
}
catch (Exception ex) {
LOG.makeAlert(ex, "Got Exception while stop()").emit();
}
finally {
//so that subsequent start() would happen, even if stop() failed with exception
lifecycleLock.exitStopAndReset();
}View on GitHub (pinned to 9b90983fd2)