SonarSource/sonarqube · warning · IllegalStateException
EsKeyStoreCli has been interrupted
Error message
EsKeyStoreCli has been interrupted
What it means
EsKeyStoreCli.waitFor waits up to one minute for the external Elasticsearch KeyStore CLI process to finish. If the waiting thread is interrupted, it restores the interrupt flag and throws IllegalStateException 'EsKeyStoreCli has been interrupted'. It signals the keystore-setup step was cancelled mid-run (typically shutdown).
Solutions
- Allow the keystore setup to complete before shutting down the server
- Check what triggered the interrupt (shutdown hook, container SIGTERM) and delay stop until after ES init
- Re-run startup to complete keystore initialization cleanly
- If interrupts are frequent, increase startup orchestration timeouts
Example fix
// orchestration before kill -TERM $PID # during keystore setup -> interrupted // after # wait for 'web process started' in logs (ES keystore done) before stopping/restarting
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure no shutdown is pending before starting ES keystore setup
if (shutdownInProgress.get()) throw new IllegalStateException("Skip ES keystore setup: shutdown pending"); Try / catch
try { esKeyStoreCli.executeWith(...); } catch (IllegalStateException e) { if (e.getMessage().equals("EsKeyStoreCli has been interrupted")) { log.warn("ES keystore setup interrupted; will retry on next start"); return; } throw e; } Prevention
- Sequence shutdowns to avoid SIGTERM during ES initialization
- Increase container stop grace periods above keystore setup duration
- Monitor startup logs and stop only after the server reports ready
- Treat interrupts during init as recoverable and retry on next start
When it happens
Trigger: The thread executing executeWith -> waitFor receives an interrupt while blocked in Process.waitFor(1, MINUTES) — normally during application shutdown.
Common situations: Server shutdown or kill while Elasticsearch keystore initialization is still running; supervision frameworks restarting the process; long-running keyStore CLI exceeding expectations combined with a shutdown request.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- At least one Elasticsearch host is required
- Can not resolve host [
- Can not resolve host [
- Can not resolve host [. Please check network settings and…
- Cannot write Elasticsearch jvm options file
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/b57158e59d7b6222.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-main/src/main/java/org/sonar/application/es/EsKeyStoreCli.java:104
try (OutputStream stdin = process.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin, StandardCharsets.UTF_8))) {
for (Entry<String, String> entry : properties.entrySet()) {
writer.write(entry.getValue());
writer.write("\n");
}
writer.flush();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
private static void waitFor(Process process) {
try {
process.waitFor(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("EsKeyStoreCli has been interrupted", e);
}
}
private static void checkExitValue(int code) {
if (code != 0) {
throw new IllegalStateException("Elasticsearch KeyStore tool exited with code: " + code);
}
}
public static class EsKeyStoreJvmOptions extends JvmOptions<EsKeyStoreJvmOptions> {
public EsKeyStoreJvmOptions(EsInstallation esInstallation) {
super(mandatoryOptions(esInstallation));
}
private static Map<String, String> mandatoryOptions(EsInstallation esInstallation) {
Map<String, String> res = LinkedHashMap.newLinkedHashMap(7);
res.put("-Xms4m", "");View on GitHub (pinned to 184c821202)