Conversation
A time-skipping sleep can outlive the activity lock it releases. Keep every decrement so the returning sleep does not leave time skipping locked. Fixes temporalio#2246 Signed-off-by: 1fanwang <1fannnw@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
Tests can stall after an activity calls
testEnv.sleep()past its start-to-close timeout. This keeps time skipping working so retries and later workflow timers can complete.Why?
The sleep temporarily releases a time-skipping lock. If the activity times out before the sleep returns, the balance can briefly become negative. The test server throws
java.lang.IllegalStateException: Unbalanced lock and unlock calls:instead of recording that decrement. When the sleep returns, it leaves an extra lock.Lock handles still reject a second unlock.
Checklist
Testing Done
JDK 21, Node 22, Temporal TypeScript 1.24.0. The unmodified base was 961a35e.
Raw output from the base:
Raw output with the fix:
The late-completion NOT_FOUND warning remains expected for an attempt that has already timed out.
Self-contained runtime reproduction
Build the checked-out revision and use its executable, rather than a downloaded test-server release:
In a separate directory, save these three files. Keep TEST_SERVER_PATH pointed at the checked-out server.
package.json:
{ "name": "temporal-2246-repro", "private": true, "version": "0.0.0", "dependencies": { "@temporalio/activity": "1.24.0", "@temporalio/testing": "1.24.0", "@temporalio/worker": "1.24.0", "@temporalio/workflow": "1.24.0" } }workflows.js:
run.cjs:
Run:
Controls for normal completion, bounded retries, and default retries followed by termination also passed. Java validation passed across the test-server suite, selected SDK timeout/timer cases, and testing-module checks.