Skip to content

Flaky test: MySQLDistTest fails with "process hasn't exited" on slow CI runners #52423

Closed

Description

@ahus1

Area

testsuite

Describe the bug

MySQLDistTest.testSuccessful and MySQLDistTest.testWarningForTooShortLifetime intermittently fail with IllegalThreadStateException: process hasn't exited.

Root cause has two parts:

  1. Startup timeout too short for MySQL migrations. The startTimeout in KeycloakRunner defaults to 120 seconds, but MySQL Liquibase migrations can exceed 2 minutes on slow CI runners (observed: ~127 seconds). When the timeout is exceeded, waitFor() throws a RuntimeException, and the finally block in KeycloakRunner.run() calls stop() on the still-running process.

  2. RawKeycloakDistribution.stop() doesn't handle graceful shutdown timeout. stop() calls keycloak.destroy() followed by keycloak.waitFor(10, SECONDS). If waitFor() returns false (process didn't stop in time), the return value is silently ignored and the code falls through to keycloak.exitValue(), which throws IllegalThreadStateException because the process is still alive. The force-kill path (destroyForcibly()) only runs on exceptions from waitFor(), not on timeout.

Version

nightly (observed on 2026-09-03)

Regression

  • The issue is a regression

Expected behavior

  • MySQL migration tests should have enough startup time to complete Liquibase migrations on slow CI runners.
  • If a Keycloak process doesn't stop gracefully within the timeout, stop() should force-kill it and report a clear error, not throw IllegalThreadStateException.

Actual behavior

java.lang.IllegalThreadStateException: process hasn't exited
    at java.base/java.lang.ProcessImpl.exitValue(ProcessImpl.java:450)
    at org.keycloak.it.utils.RawKeycloakDistribution.stop(RawKeycloakDistribution.java:221)
    at org.keycloak.it.junit5.extension.KeycloakRunner.run(KeycloakRunner.java:87)
    at org.keycloak.it.junit5.extension.CLITestExtension.beforeEach(CLITestExtension.java:107)

Both testSuccessful (186.2s) and testWarningForTooShortLifetime (160.5s) fail with this error. The failure cascades: after the first test leaks a process, subsequent tests also fail in their beforeEach when trying to stop the leaked process.

How to Reproduce?

The failure is timing-dependent and occurs on slow CI runners where MySQL Liquibase migrations take longer than 120 seconds. Example:

https://github.com/keycloak/keycloak/actions/runs/33744013985/job/100626664256?pr=52128

Anything else?

Fix (two parts):

  1. Increase startTimeout default from 120s to 300s in KeycloakRunner to accommodate slow MySQL migrations.

  2. In RawKeycloakDistribution.stop(), check the return value of waitFor(). When graceful shutdown times out, throw a RuntimeException so the existing catch block force-kills the process, captures a thread dump, and reports a clear error.

Activity

  1. added
    kind/bug
    on Sep 4, 2026
  2. added
    area/testsuite
    on Sep 4, 2026
  3. self-assigned this
    on Sep 4, 2026
  4. added
    area/dist/quarkus
    on Sep 4, 2026
  5. added theissue type on Sep 4, 2026
  6. added a commit that references this issue on Sep 4, 2026
    77068c7
  7. removed
    area/testsuite
    kind/bug
    area/dist/quarkus
    on Sep 4, 2026
  8. 13 remaining items

  9. added a commit that references this issue on Sep 16, 2026
    496267f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Fields

No fields configured for bug.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions