Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

SolverWorker can overwrite SOLVING_COMPLETED with SOLVING_ACTIVE when a best-solution save races the completion

Open
#2,730 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@rsynek is already working on this.

Since Oct 6, 2026.

Assessment

This issue has not been assessed yet.

Description

component/service

Describe the bug
SolverWorker can lose the final status of a run. A throttled best-solution save (notifyOnSave) that passes its
checks just before the run completes still writes SOLVING_ACTIVE after notifyOnComplete stored
SOLVING_COMPLETED. The run then stays SOLVING_ACTIVE forever, although solving finished.

This happened in CI on #2729: in the Pickup and Delivery Routing downstream build,
DriverRoutePlanResourcePinningTest.replanningWithPinnedShiftAndFreezeTime timed out after 5 minutes waiting for the run
to finish. The log shows the solve ended after 1 s ("Completed solving schedule" at 09:23:06.415), but the status stayed
SOLVING_ACTIVE until the test gave up ("Timed out waiting for run ...: status 'SOLVING_ACTIVE'"). The solve took
1,002 ms and the best-solution throttle is 1 s, so the last throttled save and the completion ran at the same time.

Expected behavior
Once notifyOnComplete stored SOLVING_COMPLETED, no later best-solution save changes the status of the run.

Actual behavior
notifyOnSave checks solverJobs.get(id) != null and that the stored status is SOLVING_ACTIVE, then converts the model
output, sets SOLVING_ACTIVE on the metadata and stores it. notifyOnComplete removes the job from solverJobs and stores
SOLVING_COMPLETED. Nothing makes the check and the write of the save atomic with respect to the completion, so when the
save is between its check and its write while the completion runs, the save overwrites the completed status.

To Reproduce
Reproducer test (one file, fails on main 9de70fcf every time):
https://github.com/larsbeck/timefold-solver/blob/repro-solver-worker-status-race/service/worker/src/test/java/ai/timefold/solver/service/worker/impl/SolverWorkerSaveCompleteRaceTest.java
(branch repro-solver-worker-status-race, commit
https://github.com/larsbeck/timefold-solver/commit/af686fdf)

cd service/worker
mvn test -Dtest=SolverWorkerSaveCompleteRaceTest

The test stores an active run, registers its solver job, and starts notifyOnSave on another thread. It holds that save
in its model output conversion (like a slow conversion of a large plan), runs notifyOnComplete, checks that the status
is SOLVING_COMPLETED, then releases the save. Result:

expected: SOLVING_COMPLETED
 but was: SOLVING_ACTIVE

Environment

Timefold Solver Version or Git ref: main, 9de70fcf

Output of java -version: openjdk version "25.0.2" 2026-01-20 LTS

Output of uname -a or ver: Darwin 25.6.0 arm64 (macOS); CI failure on ubuntu-latest

Additional information

A possible fix: make the save path skip its write when the run completed in the meantime, for example by serializing
notifyOnSave and notifyOnComplete per run id, or by re-checking solverJobs and the stored status under a per-run
lock right before the write.

Dominant language
Java
Stars
1.8k
Forks
238
Avg merge
3d 1h
Merged PRs (30d)
55

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TimefoldAI/timefold-solver

All issues in TimefoldAI/timefold-solver

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.