{"record":{"id":"8fd153e776126c8e","repo":"apache/druid","slug":"lookupcoordinatormanager-can-t-start","errorCode":null,"errorMessage":"LookupCoordinatorManager can't start.","messagePattern":"LookupCoordinatorManager can't start\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/server/lookup/cache/LookupCoordinatorManager.java","lineNumber":379,"sourceCode":"\n  public boolean isStarted()\n  {\n    return lifecycleLock.isStarted();\n  }\n\n  @VisibleForTesting\n  boolean awaitStarted(long waitTimeMs)\n  {\n    return lifecycleLock.awaitStarted(waitTimeMs, TimeUnit.MILLISECONDS);\n  }\n\n  // start() and stop() are synchronized so that they never run in parallel in case of ZK acting funny or druid bug and\n  // coordinator becomes leader and drops leadership in quick succession.\n  public void start()\n  {\n    synchronized (lifecycleLock) {\n      if (!lifecycleLock.canStart()) {\n        throw new ISE(\"LookupCoordinatorManager can't start.\");\n      }\n\n      try {\n        LOG.debug(\"Starting.\");\n\n        if (lookupNodeDiscovery == null) {\n          lookupNodeDiscovery = new LookupNodeDiscovery(druidNodeDiscoveryProvider);\n        }\n\n        //first ensure that previous executorService from last cycle of start/stop has finished completely.\n        //so that we don't have multiple live executorService instances lying around doing lookup management.\n        if (executorService != null &&\n            !executorService.awaitTermination(\n                lookupCoordinatorManagerConfig.getHostTimeout().getMillis() * 10,\n                TimeUnit.MILLISECONDS\n            )) {\n          throw new ISE(\"LookupCoordinatorManager executor from last start() hasn't finished. Failed to Start.\");\n        }","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/server/lookup/cache/LookupCoordinatorManager.java#L361-L397","documentation":"LookupCoordinatorManager.start() uses a lifecycle lock so it can only transition to started from the stopped state. If canStart() returns false, the manager is already started or stopping, so start() throws this IllegalStateException rather than creating a duplicate management loop.","triggerScenarios":"Calling start() twice without an intervening stop(); calling start() while a previous stop() is still in progress; leadership callbacks firing start() concurrently (guarded, but a second call still throws).","commonSituations":"Coordinator gaining leadership twice in quick succession; application code (or tests) invoking start() manually when the lifecycle already started it; not calling stop() before restart attempts.","solutions":["Check the manager's state before calling start(); only start from a stopped state.","Call stop() and let it complete before calling start() again.","If driven by leadership callbacks, verify no duplicate leadership-lost/gained events are being processed."],"exampleFix":"// before\nlookupCoordinatorManager.start();\nlookupCoordinatorManager.start(); // throws\n// after\nif (!lookupCoordinatorManager.started()) {\n  lookupCoordinatorManager.start();\n}","handlingStrategy":"try-catch","validationCode":"// Java caller:\nif (manager.started()) {\n  return; // already running, do not start again\n}","typeGuard":"public static boolean canStart(LifecycleLock lock) {\n  return lock.canStart(); // inspect state without mutating\n}","tryCatchPattern":"try {\n  manager.start();\n} catch (IllegalStateException e) {\n  if (e.getMessage().equals(\"LookupCoordinatorManager can't start.\")) {\n    LOG.debug(\"Already started or stopping; ignoring duplicate start\");\n  } else { throw e; }\n}","preventionTips":["Pair every start() with exactly one stop(); never call start() twice without stopping.","In leadership-callback code, guard start()/stop() with state checks to tolerate duplicate events.","Wait for stop() to return before issuing a new start()."],"tags":["lifecycle","state","lookups","coordination"],"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"}