Skip to content

Commit 8baa851

Browse files
Shivs11claude
andauthored
Trampolining: addition of fields to remove the infinite loops for pinned wfs (#721)
_**READ BEFORE MERGING:** All PRs require approval by both Server AND SDK teams before merging! This is why the number of required approvals is "2" and not "1"--two reviewers from the same team is NOT sufficient. If your PR is not approved by someone in BOTH teams, it may be summarily reverted._ <!-- Describe what has changed in this PR --> -WISOTT <!-- Tell your future self why have you made these changes --> - Users that could using trampolining in the near future could run into a problem, which shall only surface if the workflow author does not have AutoUpgrade as the initial CAN behaviour for their Pinned workflows. As of today, if a user does hit this case, they would have the pinned workflow CAN'ing infinite number of times. This is because a pinned workflow would commence on the pinned version (since it would have inherited pinned version set to true) and if the pinned version is different than a worker-deployment's current version, the targetDeploymentVersionChanged would be set to true in the server. This would then result in the workflow just CAN'ing all the time! - This change aims to change that by only allowing at-most one CAN for such pinned workflow executions, and it does so by remembering what the initial version was at the start of the continue-as-new. <!-- Are there any breaking changes on binary or code level? --> **Breaking changes** <!-- If this breaks the Server, please provide the Server PR to merge right after this PR was merged. --> - [PR!](temporalio/temporal#9374) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 57364bd commit 8baa851

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

openapi/openapiv2.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12040,6 +12040,15 @@
1204012040
}
1204112041
}
1204212042
},
12043+
"v1DeclinedTargetVersionUpgrade": {
12044+
"type": "object",
12045+
"properties": {
12046+
"deploymentVersion": {
12047+
"$ref": "#/definitions/v1WorkerDeploymentVersion"
12048+
}
12049+
},
12050+
"description": "Wrapper for a target deployment version that the SDK declined to upgrade to.\nSee declined_target_version_upgrade on WorkflowExecutionStartedEventAttributes."
12051+
},
1204312052
"v1DeleteNexusEndpointResponse": {
1204412053
"type": "object"
1204512054
},
@@ -17719,6 +17728,10 @@
1771917728
"eagerExecutionAccepted": {
1772017729
"type": "boolean",
1772117730
"description": "A boolean indicating whether the SDK has asked to eagerly execute the first workflow task for this workflow and\neager execution was accepted by the server.\nOnly populated by server with version >= 1.29.0."
17731+
},
17732+
"declinedTargetVersionUpgrade": {
17733+
"$ref": "#/definitions/v1DeclinedTargetVersionUpgrade",
17734+
"description": "During a previous run of this workflow, the server may have notified the SDK\nthat the Target Worker Deployment Version changed, but the SDK declined to\nupgrade (e.g., by continuing-as-new with PINNED behavior). This field records\nthe target version that was declined.\n\nThis is a wrapper message to distinguish \"never declined\" (nil wrapper) from\n\"declined an unversioned target\" (non-nil wrapper with nil deployment_version).\n\nUsed internally by the server during continue-as-new and retry.\nShould not be read or interpreted by SDKs."
1772217735
}
1772317736
},
1772417737
"title": "Always the first event in workflow history"

openapi/openapiv3.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9226,6 +9226,14 @@ components:
92269226
data:
92279227
type: string
92289228
format: bytes
9229+
DeclinedTargetVersionUpgrade:
9230+
type: object
9231+
properties:
9232+
deploymentVersion:
9233+
$ref: '#/components/schemas/WorkerDeploymentVersion'
9234+
description: |-
9235+
Wrapper for a target deployment version that the SDK declined to upgrade to.
9236+
See declined_target_version_upgrade on WorkflowExecutionStartedEventAttributes.
92299237
DeleteNexusEndpointResponse:
92309238
type: object
92319239
properties: {}
@@ -16528,6 +16536,20 @@ components:
1652816536
A boolean indicating whether the SDK has asked to eagerly execute the first workflow task for this workflow and
1652916537
eager execution was accepted by the server.
1653016538
Only populated by server with version >= 1.29.0.
16539+
declinedTargetVersionUpgrade:
16540+
allOf:
16541+
- $ref: '#/components/schemas/DeclinedTargetVersionUpgrade'
16542+
description: |-
16543+
During a previous run of this workflow, the server may have notified the SDK
16544+
that the Target Worker Deployment Version changed, but the SDK declined to
16545+
upgrade (e.g., by continuing-as-new with PINNED behavior). This field records
16546+
the target version that was declined.
16547+
16548+
This is a wrapper message to distinguish "never declined" (nil wrapper) from
16549+
"declined an unversioned target" (non-nil wrapper with nil deployment_version).
16550+
16551+
Used internally by the server during continue-as-new and retry.
16552+
Should not be read or interpreted by SDKs.
1653116553
description: Always the first event in workflow history
1653216554
WorkflowExecutionTerminatedEventAttributes:
1653316555
type: object

temporal/api/history/v1/message.proto

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,24 @@ message WorkflowExecutionStartedEventAttributes {
184184
// eager execution was accepted by the server.
185185
// Only populated by server with version >= 1.29.0.
186186
bool eager_execution_accepted = 38;
187+
188+
// During a previous run of this workflow, the server may have notified the SDK
189+
// that the Target Worker Deployment Version changed, but the SDK declined to
190+
// upgrade (e.g., by continuing-as-new with PINNED behavior). This field records
191+
// the target version that was declined.
192+
//
193+
// This is a wrapper message to distinguish "never declined" (nil wrapper) from
194+
// "declined an unversioned target" (non-nil wrapper with nil deployment_version).
195+
//
196+
// Used internally by the server during continue-as-new and retry.
197+
// Should not be read or interpreted by SDKs.
198+
DeclinedTargetVersionUpgrade declined_target_version_upgrade = 40;
199+
}
200+
201+
// Wrapper for a target deployment version that the SDK declined to upgrade to.
202+
// See declined_target_version_upgrade on WorkflowExecutionStartedEventAttributes.
203+
message DeclinedTargetVersionUpgrade {
204+
temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 1;
187205
}
188206

189207
message WorkflowExecutionCompletedEventAttributes {

0 commit comments

Comments
 (0)