{"record":{"id":"8f71211f10f55180","repo":"apache/druid","slug":"can-t-start-8f7121","errorCode":null,"errorMessage":"can't start.","messagePattern":"can't start\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/db/cache/CoordinatorPollingBasicAuthenticatorCacheManager.java","lineNumber":102,"sourceCode":"      BasicAuthCommonCacheConfig commonCacheConfig,\n      @Smile ObjectMapper objectMapper,\n      @Coordinator ServiceClient coordinatorClient\n  )\n  {\n    this.exec = Execs.scheduledSingleThreaded(\"BasicAuthenticatorCacheManager-Exec--%d\");\n    this.injector = injector;\n    this.commonCacheConfig = commonCacheConfig;\n    this.objectMapper = objectMapper;\n    this.cachedUserMaps = new ConcurrentHashMap<>();\n    this.authenticatorPrefixes = new HashSet<>();\n    this.coordinatorClient = coordinatorClient;\n  }\n\n  @LifecycleStart\n  public void start()\n  {\n    if (!lifecycleLock.canStart()) {\n      throw new ISE(\"can't start.\");\n    }\n\n    LOG.info(\"Starting CoordinatorPollingBasicAuthenticatorCacheManager.\");\n\n    try {\n      initUserMaps();\n\n      ScheduledExecutors.scheduleWithFixedDelay(\n          exec,\n          new Duration(commonCacheConfig.getPollingPeriod()),\n          new Duration(commonCacheConfig.getPollingPeriod()),\n          () -> {\n            try {\n              long randomDelay = ThreadLocalRandom.current().nextLong(0, commonCacheConfig.getMaxRandomDelay());\n              LOG.debug(\"Inserting cachedUserMaps random polling delay of [%s] ms\", randomDelay);\n              Thread.sleep(randomDelay);\n\n              LOG.debug(\"Scheduled user cache poll is running\");","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/db/cache/CoordinatorPollingBasicAuthenticatorCacheManager.java#L84-L120","documentation":"Thrown by CoordinatorPollingBasicAuthenticatorCacheManager.start when lifecycleLock.canStart() returns false. This manager polls the coordinator for authenticator user maps; like all Druid lifecycle components it may only transition from an idle state into started. Double-start, start-after-stop, or concurrent start calls all fail here.","triggerScenarios":"start() called twice on the same manager instance; start() after stop(); racing lifecycle threads where one thread already claimed the transition; test code manually starting the manager after the suite lifecycle already did.","commonSituations":"Incorrect lifecycle registration order; test teardown not stopping the manager between cases; leadership handover code restarting the manager without proper stop first.","solutions":["Call stop() and create a fresh instance instead of re-starting a started/stopped manager","Verify the manager is registered once in the lifecycle and started exactly once","Guard callers with a state check before invoking start","In tests, stop the manager in @AfterEach to reset state"],"exampleFix":"// before\nmanager.start(); manager.start(); // second call throws\n// after\nif (!started) { manager.start(); started = true; }","handlingStrategy":"type-guard","validationCode":"boolean startOnce(AtomicBoolean started, CoordinatorPollingBasicAuthenticatorCacheManager m) { return started.compareAndSet(false, true) && (m.start(), true); }","typeGuard":"boolean isStartable(CoordinatorPollingBasicAuthenticatorCacheManager m) { try { return m != null && !m.started(); } catch (UnsupportedOperationException e) { return true; } } // track your own started flag","tryCatchPattern":"try { manager.start(); } catch (ISE e) { LOG.warn(\"cache manager start rejected (already started/stopped)\"); }","preventionTips":["Register the manager once in the lifecycle and start via the framework only","In tests, stop the manager in @AfterEach and recreate per test","Guard start calls with an idempotency flag","Keep leadership-change handlers restart-safe (stop, await, recreate)"],"tags":["lifecycle","illegal-state","polling"],"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-14T05:17:10.506Z"}