{"record":{"id":"f3165b0ba5377139","repo":"apache/druid","slug":"interrupted-waiting-for-jetty-shutdown","errorCode":null,"errorMessage":"Interrupted waiting for jetty shutdown.","messagePattern":"Interrupted waiting for jetty shutdown\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java","lineNumber":459,"sourceCode":"          }\n\n          @Override\n          public void stop()\n          {\n            try {\n              final long unannounceDelay = config.getUnannouncePropagationDelay().toStandardDuration().getMillis();\n              if (unannounceDelay > 0) {\n                log.info(\"Sleeping %s ms for unannouncement to propagate.\", unannounceDelay);\n                Thread.sleep(unannounceDelay);\n              } else {\n                log.debug(\"Skipping unannounce wait.\");\n              }\n              log.debug(\"Stopping Jetty Server...\");\n              server.stop();\n            }\n            catch (InterruptedException e) {\n              Thread.currentThread().interrupt();\n              throw new RE(e, \"Interrupted waiting for jetty shutdown.\");\n            }\n            catch (Exception e) {\n              log.warn(e, \"Unable to stop Jetty server.\");\n            }\n          }\n        },\n        Lifecycle.Stage.SERVER\n    );\n\n    if (!config.isShowDetailedJettyErrors()) {\n      server.setErrorHandler(new ErrorHandler()\n      {\n        @Override\n        public boolean handle(\n            Request baseRequest,\n            Response response,\n            Callback callback\n        ) throws Exception","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java#L441-L477","documentation":"When the Druid node shuts down, a lifecycle stop hook stops the Jetty server and waits for the stop to complete. If that wait is interrupted (the stopping thread receives an interrupt), the module re-interrupts the thread and throws this ResourceInterruptedException to signal shutdown did not complete cleanly.","triggerScenarios":"Calling stop() on the Jetty lifecycle while another thread interrupts the stopping thread, e.g. during fast process shutdown, Lifecycle.stop() racing with JVM exit, or a watchdog thread interrupting a hung shutdown.","commonSituations":"kill -TERM / systemd stop racing with other lifecycle shutdown; test frameworks interrupting threads between tests; a coordinator dropping leadership triggering stop while the process is being torn down.","solutions":["Usually benign during process exit: verify the node terminated and ignore if only occurring at shutdown.","If recurring, check what is interrupting the shutdown thread (watchdog, test harness) and fix that component.","Ensure Lifecycle.stop() is called from a thread that is not being interrupted during teardown."],"exampleFix":"// before\nlifecycle.stop();  // thread may be interrupted here\n// after\ntry {\n  lifecycle.stop();\n} catch (ResourceInterruptedException e) {\n  LOG.warn(e, \"Jetty shutdown interrupted; continuing teardown\");\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  lifecycle.stop();\n} catch (ResourceInterruptedException e) {\n  if (e.getMessage().contains(\"Interrupted waiting for jetty shutdown\")) {\n  LOG.warn(e, \"Jetty shutdown was interrupted; server may not have stopped cleanly\");\n  } else { throw e; }\n}","preventionTips":["Avoid interrupting the shutdown thread; let Lifecycle.stop() run to completion during teardown.","In tests, join or await lifecycle-stop threads rather than interrupting them between tests.","Treat occurrences at JVM exit as benign; investigate only if they appear mid-run."],"tags":["shutdown","jetty","interruption","lifecycle"],"backgroundTag":"operation-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"}