Skip to content

Fix flaky ConductorTest latch timeouts caused by ChaosTest starving the common ForkJoinPool#458

Open
maxdml wants to merge 2 commits into
mainfrom
fix-chaostest-commonpool-starvation
Open

Fix flaky ConductorTest latch timeouts caused by ChaosTest starving the common ForkJoinPool#458
maxdml wants to merge 2 commits into
mainfrom
fix-chaostest-commonpool-starvation

Conversation

@maxdml

@maxdml maxdml commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

CI intermittently fails a random ConductorTest with message latch timed out (e.g. canGetWorkflowEventsThrows()[3] in run 79520581511, failing all 3 retries).

Root cause: ChaosTest.toxiProxyTest launched dbLossBetweenSteps via a bare CompletableFuture.supplyAsync(...), which runs on the JVM-shared common ForkJoinPool. While the test's toxiproxy partition is active (~3s), that worker sits blocked inside SystemDatabase.dbRetry backoff loops. On CI runners the common pool has only ~3 workers, and the run's logs show the pool fully stalled for 3.2s — with zero common-pool activity — exactly spanning all three retries of the failing test.

The Conductor's WebSocket callbacks (onOpen/onText) and message handlers also dispatch on the common pool, so during the stall the conductor client never completed its handshake: the test server saw onOpen and sent the request, but the client-side connect future was still pending when Conductor.stop cancelled it at teardown. Suite-wide, the test server saw 113 handshakes while the client completed only 106.

The flake only reproduces when a ConductorTest happens to overlap one of ChaosTest's induced partitions, which is why it comes and goes.

Fix

Run the deliberately-blocked startWorkflow on a dedicated thread instead of the common pool. A platform thread is used (not virtual) because the module targets --release 17.

Testing

  • :transact:compileTestJava passes
  • CI=true ./gradlew :transact:test --tests dev.dbos.transact.database.ChaosTest.toxiProxyTest: all 5 repetitions pass (test is ci-only-tagged)

Note

This removes the known trigger, but the Conductor still depends on the common pool for its WebSocket callbacks and handlers (Conductor.java:795+). Anything that saturates the common pool for >1s could reproduce the symptom, including in production. Giving the Conductor an explicit executor is a possible follow-up.

toxiProxyTest launched dbLossBetweenSteps via a bare CompletableFuture.supplyAsync,
so the worker sat blocked in dbRetry for the whole 3s induced network partition.
On small CI runners this stalled the entire common pool, starving concurrently
running ConductorTests whose WebSocket callbacks dispatch there — causing flaky
"message latch timed out" failures. Use a dedicated thread instead.
@devhawk devhawk added the bug Something isn't working label Jul 16, 2026

// Scenario 1: proxy disabled — simulates a sustained network partition
proxy.disable();
// Dedicated thread: this blocks in dbRetry while the proxy is down, and must

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we run this test @isolated and/or @execution(ExecutionMode.SAME_THREAD)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thread would have supplyAsync run on the same coomon pool and isolated slows down test without really solving the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants