{"record":{"id":"d2127d7ac6204165","repo":"apache/druid","slug":"interrupted-while-waiting-for-queryable-server-ini","errorCode":null,"errorMessage":"Interrupted while waiting for queryable server initial successful sync.","messagePattern":"Interrupted while waiting for queryable server initial successful sync\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java","lineNumber":392,"sourceCode":"   */\n  private void serverInventoryInitialized()\n  {\n    long start = System.currentTimeMillis();\n    long serverSyncWaitTimeout = config.getServerTimeout() + 2 * ChangeRequestHttpSyncer.HTTP_TIMEOUT_EXTRA_MS;\n\n    List<DruidServerHolder> uninitializedServers = new ArrayList<>();\n    for (DruidServerHolder server : servers.values()) {\n      if (!server.isSyncedSuccessfullyAtleastOnce()) {\n        uninitializedServers.add(server);\n      }\n    }\n\n    while (!uninitializedServers.isEmpty() && ((System.currentTimeMillis() - start) < serverSyncWaitTimeout)) {\n      try {\n        Thread.sleep(5000);\n      }\n      catch (InterruptedException ex) {\n        throw new RE(ex, \"Interrupted while waiting for queryable server initial successful sync.\");\n      }\n\n      log.info(\"Waiting for [%d] servers to sync successfully.\", uninitializedServers.size());\n      uninitializedServers.removeIf(\n          serverHolder -> serverHolder.isSyncedSuccessfullyAtleastOnce()\n                          || serverHolder.isStopped()\n      );\n    }\n\n    if (uninitializedServers.isEmpty()) {\n      log.info(\"All servers have been synced successfully at least once.\");\n    } else {\n      for (DruidServerHolder server : uninitializedServers) {\n        log.warn(\n            \"Server[%s] might not yet be synced successfully. We will continue to retry that in the background.\",\n            server.druidServer.getName()\n        );\n      }","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java#L374-L410","documentation":"serverInventoryInitialized() blocks waiting until all queryable servers report at least one successful sync (or serverSyncWaitTimeout elapses), sleeping in 5s intervals. If the sleeping thread is interrupted, it rethrows as a RuntimeException with this message — callers cannot get a reliable answer about inventory readiness.","triggerScenarios":"Thread waiting in the poll loop receives Thread.interrupt() — typically during JVM/server shutdown or task cancellation while uninitialized servers remain.","commonSituations":"Druid broker shutdown while some historical servers never synced; overloading serverSyncWaitTimeout so a shutdown interrupts a long wait; test frameworks interrupting timed-out threads.","solutions":["Restore the interrupt flag and exit the readiness wait gracefully if you own the calling code","Ensure shutdown ordering stops the inventory view before interrupting its waiting threads","Check why servers are not syncing (network, discovery) if interrupts coincide with long waits","Increase serverSyncWaitTimeout so waits finish before shutdown interrupts occur"],"exampleFix":"// before\nview.serverInventoryInitialized(); // RE on interrupt\n// after\ntry {\n  view.serverInventoryInitialized();\n} catch (RuntimeException e) {\n  Thread.currentThread().interrupt();\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// check readiness without blocking, if exposed, or wait within timeout budget\nlong deadline = System.currentTimeMillis() + timeoutMs;","typeGuard":null,"tryCatchPattern":"try { view.serverInventoryInitialized(); } catch (RuntimeException e) { Thread.currentThread().interrupt(); throw e; }","preventionTips":["Stop the inventory view before interrupting threads at shutdown","Size serverSyncWaitTimeout to expected cluster sync time","Monitor why servers stay unsynced"],"tags":["interrupt","shutdown","threading"],"backgroundTag":"thread-interrupted","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"}