apache/druid · error · IllegalStateException

can't stop.

Error message

can't stop.

What it means

HttpServerInventoryView.stop() throws ISE when lifecycleLock.canStop() is false, meaning the lifecycle was never started or has already been stopped. It prevents stopping a component that is not in a running state.

Source

Thrown at server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java:261

            this::emitServerStatusMetrics
        );

        lifecycleLock.started();
      }
      finally {
        lifecycleLock.exitStart();
      }

      log.info("Started executor[%s].", execNamePrefix);
    }
  }

  @LifecycleStop
  public void stop()
  {
    synchronized (lifecycleLock) {
      if (!lifecycleLock.canStop()) {
        throw new ISE("can't stop.");
      }

      log.info("Stopping executor[%s].", execNamePrefix);

      if (inventorySyncExecutor != null) {
        inventorySyncExecutor.shutdownNow();
      }
      if (monitoringExecutor != null) {
        monitoringExecutor.shutdownNow();
      }

      log.info("Stopped executor[%s].", execNamePrefix);
    }
  }

  @Override
  public void registerSegmentCallback(
      Executor exec,

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Track whether start() succeeded and only call stop() in that case
  2. Wrap stop() in a check or catch ISE for idempotent teardown paths
  3. In tests, use a try/finally that tolerates a never-started instance
  4. Create a fresh instance if the lifecycle must be restarted after stop

Example fix

// before
view.stop(); // may throw ISE if never started
// after
try {
  view.stop();
} catch (IllegalStateException e) {
  // already stopped or never started
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (viewStarted) view.stop();

Try / catch

try { view.stop(); } catch (IllegalStateException e) { /* never started or already stopped */ }

Prevention

When it happens

Trigger: Calling stop() before start(); calling stop() twice; stopping an instance whose lifecycle was never advanced (e.g. construction failed before start).

Common situations: Shutdown hooks registered multiple times; test teardown calling stop() when setup failed before start(); idempotent-shutdown attempts on an already-stopped coordinator component.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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