-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workflow.getVersion() could cause NonDeterminsticError with multithreading + timer #1430
Comments
Which version of java-sdk are we talking about? |
These are the versions we are using:
|
Confirm. State machine bug. sdk-java/temporal-sdk/src/main/java/io/temporal/internal/sync/SyncWorkflowContext.java Line 678 in 0ab17d8
It needs a very careful and probably very ugly fix to keep it backwards compatible. If we just fix it "right" and make getVersion not yielding, we will break existing histories generated by yielding version. |
Just an idea. We could add a new field in workflow task started/completed to store some metadata of the sdk for the first workflow task of the workflow. Use the meta data (eg the sdk version) to decide the new behavior . This new field can be generic to solve many future problems as well |
Hey Temporal team,
We found that Workflow.getVersion() is letting workflow thread to yield, which causes NonDeterminsticError because the thread execution ordering is changed — this has made it very hard for us to use this getVersion().
Imagine we have two threads:
ThreadA:
ThreadB
And thread A is invoked first.
And we got a JSON history for replay test. The history looks like this:
Then we are changing thread A to :
Then the replay test gets broken.
Because the thread A will yield at Workflow.getVersion() and thread B will then try to schedule before the activity A.
In Java SDK, it’s enforcing the eventId to be exactly matched with the history. So the replay test would run into NDE error.
Some thoughts to improve:
I think GoSDK is only forcing within a workflow task completed batch commands. This may be more reasonable because I don’t think the order really matter within a workflow task results.
Or if we could do special case in Workflow.getVersion() to let it not yield the current thread…
To reproduce
Got a history for replay
Then change the code to:
And this should break the replay test
The text was updated successfully, but these errors were encountered: