Skip to content

Add preferred version provider to worker options#2942

Merged
Sushisource merged 4 commits into
mainfrom
sj/preferred-version
Jul 9, 2026
Merged

Add preferred version provider to worker options#2942
Sushisource merged 4 commits into
mainfrom
sj/preferred-version

Conversation

@Sushisource

Copy link
Copy Markdown
Member

What was changed

Per a customer request, added a way to specify a "preferred" version to use when making a get version call which may not necessarily be the maxVersion which would normally be used when a getVersion call is encountered for the first time.

This is accomplished by adding a worker option: setPreferredVersionProvider which accepts a callback that can be used to determine the version for a given call.

Why?

Users would like to have a way to perform a rolling deployment of a worker change that includes an introduction of a getVersion call to a workflow. Without this capability, such a rolling deployment means that if a worker with the new code picks up a task, runs the call, and then the workflow replays on the old code, a WFT failure occurs because the old code is missing the call. (The other direction is acceptable).

This makes rolling deployments noisy, especially if they proceed slowly.

Checklist

  1. Closes Add preferred version worker option #2941

  2. How was this tested:
    Added tests

  3. Any docs updates needed?

@Sushisource Sushisource marked this pull request as ready for review July 8, 2026 00:27
@Sushisource Sushisource requested a review from a team as a code owner July 8, 2026 00:27
Comment thread temporal-sdk/src/main/java/io/temporal/worker/PreferredVersionProvider.java Outdated
}
}

public static <T> T readOnly(Functions.Func<T> func) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Quinn-With-Two-Ns Seemed useful. LMK if you think I should refactor other sites to use this that are doing the same thing by hand.

Comment thread temporal-sdk/src/main/java/io/temporal/internal/replay/WorkflowInfoImpl.java Outdated
@Sushisource Sushisource enabled auto-merge (squash) July 8, 2026 20:28
@Sushisource Sushisource force-pushed the sj/preferred-version branch from 694dc37 to 94c226f Compare July 9, 2026 17:14
@Sushisource Sushisource merged commit b8ace30 into main Jul 9, 2026
18 checks passed
@Sushisource Sushisource deleted the sj/preferred-version branch July 9, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add preferred version worker option

3 participants