{"record":{"id":"deef73a278667d41","repo":"apache/druid","slug":"classname-is-not-started","errorCode":null,"errorMessage":"${className} is not started","messagePattern":"(.+?) is not started","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java","lineNumber":291,"sourceCode":"    ReentrantReadWriteLock.WriteLock lock = startStopPollLock.writeLock();\n    lock.lock();\n    try {\n      exec.shutdownNow();\n      exec = null;\n    }\n    finally {\n      lock.unlock();\n    }\n  }\n\n  @Override\n  public void startPollingDatabasePeriodically()\n  {\n    ReentrantReadWriteLock.WriteLock lock = startStopPollLock.writeLock();\n    lock.lock();\n    try {\n      if (exec == null) {\n        throw new IllegalStateException(getClass().getName() + \" is not started\");\n      }\n      if (isPollingDatabasePeriodically()) {\n        return;\n      }\n\n      PeriodicDatabasePoll periodicDatabasePoll = new PeriodicDatabasePoll();\n      latestDatabasePoll = periodicDatabasePoll;\n\n      startPollingCount++;\n      currentStartPollingOrder = startPollingCount;\n      final long localStartOrder = currentStartPollingOrder;\n\n      periodicPollTaskFuture = exec.scheduleWithFixedDelay(\n          createPollTaskForStartOrder(localStartOrder, periodicDatabasePoll),\n          0,\n          periodicPollDelay.getMillis(),\n          TimeUnit.MILLISECONDS\n      );","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java#L273-L309","documentation":"SqlSegmentsMetadataManager throws this IllegalStateException from startPollingDatabasePeriodically() when the manager's periodic polling is requested but the manager lifecycle was never started via start(). Internally, the executor field (exec) is null, meaning start() was not called (or stop() already tore it down). It is a lifecycle-ordering guard: polling cannot be scheduled without the executor created during start().","triggerScenarios":"Calling startPollingDatabasePeriodically() before start() has been invoked on the manager, or after stop() released the polling executor (exec == null) while holding the startStopPollLock write lock.","commonSituations":"Coordinator/Historical node wiring where the SqlSegmentsMetadataManager is injected but its Lifecycle was never started; custom code or tests that call startPollingDatabasePeriodically() directly without the Druid lifecycle; calling polling start after a shutdown hook already stopped the manager.","solutions":["Ensure the Druid Lifecycle (or startup injector) calls start() on SqlSegmentsMetadataManager before startPollingDatabasePeriodically().","Check for double lifecycle management: some component may have called stop() before your startPollingDatabasePeriodically() call.","In tests, call manager.start() in setup before enabling periodic polling.","Wrap the call in a state check: only start polling when the manager reports started."],"exampleFix":"// before\nsqlSegmentsMetadataManager.startPollingDatabasePeriodically();\n// after\nsqlSegmentsMetadataManager.start(); // must precede polling start\nsqlSegmentsMetadataManager.startPollingDatabasePeriodically();","handlingStrategy":"validation","validationCode":"// before enabling polling\nif (manager.isStarted()) { // check the manager's own state if exposed\n  manager.startPollingDatabasePeriodically();\n}","typeGuard":"boolean canPoll = manager != null && java.util.concurrent.atomic status-check: poll only when exec-backed lifecycle has started;","tryCatchPattern":"try {\n  manager.startPollingDatabasePeriodically();\n} catch (IllegalStateException e) {\n  // manager not started: initialize lifecycle first or reschedule\n}","preventionTips":["Always start SqlSegmentsMetadataManager through the Druid Lifecycle before enabling polling","Do not manually interleave start/stop with polling calls","In tests, call start() in @BeforeEach/setup"],"tags":["lifecycle","initialization","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}