Skip to content

Commit e27f98c

Browse files
carlydfSushisource
andauthored
Add CONTINUE_AS_NEW_SUGGESTED_REASON and CONTINUE_AS_NEW_VERSIONING_BEHAVIOR enums. (#677)
_**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 --> - Allow user to specify in ContinueAsNewOptions what the initial versioning behavior of the continued-as-new workflow should be. User can say AutoUpgrade if they want their workflow to upgrade on continue-as-new. - Define `CONTINUE_AS_NEW_SUGGESTED_REASON`. `suggest_continue_as_new = true, reason = TARGET_WORKER_DEPLOYMENT_VERSION_CHANGED` will be sent to the SDK with each workflow task, if the target version of the workflow is different than the deployment version that the workflow is currently on. Workflow code should listen to this and decide whether to ContinueAsNew based on the suggestion and reason(s) for the suggestion. <!-- Tell your future self why have you made these changes --> We want to offer a way for users to guarantee workflow pinning within a run, while still upgrading to the latest Current/Ramping version on the continue-as-new boundary. In Phase 2 of Trampolining (which is "proactive wakeup for sleeping workflows"), a separate workflow attribute will be added to allow workflows to receive a proactive wake-up when a new version is available. Pro-active wakeup would cause sleeping workflows to wake up and have the opportunity to check `continue_as_new_suggested` and continue-as-new if they choose. This is orthogonal to "will I upgrade when I continue-as-new," and applicable to both Pinned and AutoUpgrade workflows. <!-- 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. --> **Server PR** temporalio/temporal#8784 --------- Co-authored-by: Spencer Judge <[email protected]>
1 parent de624ee commit e27f98c

File tree

6 files changed

+157
-40
lines changed

6 files changed

+157
-40
lines changed

openapi/openapiv2.json

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8561,7 +8561,7 @@
85618561
"PINNED_OVERRIDE_BEHAVIOR_PINNED"
85628562
],
85638563
"default": "PINNED_OVERRIDE_BEHAVIOR_UNSPECIFIED",
8564-
"description": "Used to specify different sub-types of Pinned override that we plan to add in the future.\n\n - PINNED_OVERRIDE_BEHAVIOR_UNSPECIFIED: Unspecified.\n - PINNED_OVERRIDE_BEHAVIOR_PINNED: Override workflow behavior to be Pinned."
8564+
"description": " - PINNED_OVERRIDE_BEHAVIOR_UNSPECIFIED: Unspecified.\n - PINNED_OVERRIDE_BEHAVIOR_PINNED: Override workflow behavior to be Pinned."
85658565
},
85668566
"WorkerConfigAutoscalingPollerBehavior": {
85678567
"type": "object",
@@ -11841,6 +11841,15 @@
1184111841
"default": "CONTINUE_AS_NEW_INITIATOR_UNSPECIFIED",
1184211842
"title": "- CONTINUE_AS_NEW_INITIATOR_WORKFLOW: The workflow itself requested to continue as new\n - CONTINUE_AS_NEW_INITIATOR_RETRY: The workflow continued as new because it is retrying\n - CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE: The workflow continued as new because cron has triggered a new execution"
1184311843
},
11844+
"v1ContinueAsNewVersioningBehavior": {
11845+
"type": "string",
11846+
"enum": [
11847+
"CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_UNSPECIFIED",
11848+
"CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_AUTO_UPGRADE"
11849+
],
11850+
"default": "CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_UNSPECIFIED",
11851+
"description": "Experimental. Defines the versioning behavior to be used by the first task of a new workflow run in a continue-as-new chain.\n\n - CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_AUTO_UPGRADE: Start the new run with AutoUpgrade behavior. Use the Target Version of the workflow's task queue at\nstart-time, as AutoUpgrade workflows do. After the first workflow task completes, use whatever\nVersioning Behavior the workflow is annotated with in the workflow code.\n\nNote that if the previous workflow had a Pinned override, that override will be inherited by the\nnew workflow run regardless of the ContinueAsNewVersioningBehavior specified in the continue-as-new\ncommand. If a Pinned override is inherited by the new run, and the new run starts with AutoUpgrade\nbehavior, the base version of the new run will be the Target Version as described above, but the\neffective version will be whatever is specified by the Versioning Override until the override is removed."
11852+
},
1184411853
"v1ContinueAsNewWorkflowExecutionCommandAttributes": {
1184511854
"type": "object",
1184611855
"properties": {
@@ -11896,6 +11905,10 @@
1189611905
"inheritBuildId": {
1189711906
"type": "boolean",
1189811907
"description": "If this is set, the new execution inherits the Build ID of the current execution. Otherwise,\nthe assignment rules will be used to independently assign a Build ID to the new execution.\nDeprecated. Only considered for versioning v0.2."
11908+
},
11909+
"initialVersioningBehavior": {
11910+
"$ref": "#/definitions/v1ContinueAsNewVersioningBehavior",
11911+
"description": "Experimental. Optionally decide the versioning behavior that the first task of the new run should use.\nFor example, choose to AutoUpgrade on continue-as-new instead of inheriting the pinned version\nof the previous run."
1189911912
}
1190011913
}
1190111914
},
@@ -16641,6 +16654,18 @@
1664116654
},
1664216655
"description": "StructuredCalendarSpec describes an event specification relative to the\ncalendar, in a form that's easy to work with programmatically. Each field can\nbe one or more ranges.\nA timestamp matches if at least one range of each field matches the\ncorresponding fields of the timestamp, except for year: if year is missing,\nthat means all years match. For all fields besides year, at least one Range\nmust be present to match anything.\nRelative expressions such as \"last day of the month\" or \"third Monday\" are not currently\nrepresentable; callers must enumerate the concrete days they require."
1664316656
},
16657+
"v1SuggestContinueAsNewReason": {
16658+
"type": "string",
16659+
"enum": [
16660+
"SUGGEST_CONTINUE_AS_NEW_REASON_UNSPECIFIED",
16661+
"SUGGEST_CONTINUE_AS_NEW_REASON_HISTORY_SIZE_TOO_LARGE",
16662+
"SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_HISTORY_EVENTS",
16663+
"SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_UPDATES",
16664+
"SUGGEST_CONTINUE_AS_NEW_REASON_TARGET_WORKER_DEPLOYMENT_VERSION_CHANGED"
16665+
],
16666+
"default": "SUGGEST_CONTINUE_AS_NEW_REASON_UNSPECIFIED",
16667+
"description": "SuggestContinueAsNewReason specifies why SuggestContinueAsNew is true.\n\n - SUGGEST_CONTINUE_AS_NEW_REASON_HISTORY_SIZE_TOO_LARGE: Workflow History size is getting too large.\n - SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_HISTORY_EVENTS: Workflow History event count is getting too large.\n - SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_UPDATES: Workflow's count of completed plus in-flight updates is too large.\n - SUGGEST_CONTINUE_AS_NEW_REASON_TARGET_WORKER_DEPLOYMENT_VERSION_CHANGED: Workflow's Target Worker Deployment Version is different from its\nCurrent Version and the workflow is versioned."
16668+
},
1664416669
"v1TaskIdBlock": {
1664516670
"type": "object",
1664616671
"properties": {
@@ -17382,18 +17407,18 @@
1738217407
"VERSIONING_BEHAVIOR_AUTO_UPGRADE"
1738317408
],
1738417409
"default": "VERSIONING_BEHAVIOR_UNSPECIFIED",
17385-
"description": "Versioning Behavior specifies if and how a workflow execution moves between Worker Deployment\nVersions. The Versioning Behavior of a workflow execution is typically specified by the worker\nwho completes the first task of the execution, but is also overridable manually for new and\nexisting workflows (see VersioningOverride).\nExperimental. Worker Deployments are experimental and might significantly change in the future.\n\n - VERSIONING_BEHAVIOR_UNSPECIFIED: Workflow execution does not have a Versioning Behavior and is called Unversioned. This is the\nlegacy behavior. An Unversioned workflow's task can go to any Unversioned worker (see\n`WorkerVersioningMode`.)\nUser needs to use Patching to keep the new code compatible with prior versions when dealing\nwith Unversioned workflows.\n - VERSIONING_BEHAVIOR_PINNED: Workflow will start on the Current Deployment Version of its Task Queue, and then\nwill be pinned to that same Deployment Version until completion (the Version that\nthis Workflow is pinned to is specified in `versioning_info.version`).\nThis behavior eliminates most of compatibility concerns users face when changing their code.\nPatching is not needed when pinned workflows code change.\nCan be overridden explicitly via `UpdateWorkflowExecutionOptions` API to move the\nexecution to another Deployment Version.\nActivities of `PINNED` workflows are sent to the same Deployment Version. Exception to this\nwould be when the activity Task Queue workers are not present in the workflow's Deployment\nVersion, in which case the activity will be sent to the Current Deployment Version of its own\ntask queue.\n - VERSIONING_BEHAVIOR_AUTO_UPGRADE: Workflow will automatically move to the Current Deployment Version of its Task Queue when the\nnext workflow task is dispatched.\nAutoUpgrade behavior is suitable for long-running workflows as it allows them to move to the\nlatest Deployment Version, but the user still needs to use Patching to keep the new code\ncompatible with prior versions for changed workflow types.\nActivities of `AUTO_UPGRADE` workflows are sent to the Deployment Version of the workflow\nexecution (as specified in versioning_info.version based on the last completed\nworkflow task). Exception to this would be when the activity Task Queue workers are not\npresent in the workflow's Deployment Version, in which case, the activity will be sent to a\ndifferent Deployment Version according to the Current Deployment Version of its own task\nqueue.\nWorkflows stuck on a backlogged activity will still auto-upgrade if the Current Deployment\nVersion of their Task Queue changes, without having to wait for the backlogged activity to\ncomplete on the old Version."
17410+
"description": "Versioning Behavior specifies if and how a workflow execution moves between Worker Deployment\nVersions. The Versioning Behavior of a workflow execution is typically specified by the worker\nwho completes the first task of the execution, but is also overridable manually for new and\nexisting workflows (see VersioningOverride).\nExperimental. Worker Deployments are experimental and might significantly change in the future.\n\n - VERSIONING_BEHAVIOR_UNSPECIFIED: Workflow execution does not have a Versioning Behavior and is called Unversioned. This is the\nlegacy behavior. An Unversioned workflow's task can go to any Unversioned worker (see\n`WorkerVersioningMode`.)\nUser needs to use Patching to keep the new code compatible with prior versions when dealing\nwith Unversioned workflows.\n - VERSIONING_BEHAVIOR_PINNED: Workflow will start on its Target Version and then will be pinned to that same Deployment\nVersion until completion (the Version that this Workflow is pinned to is specified in\n`versioning_info.version` and is the Pinned Version of the Workflow).\n\nThe workflow's Target Version is the Current Version of its Task Queue, or, if the\nTask Queue has a Ramping Version with non-zero Ramp Percentage `P`, the workflow's Target\nVersion has a P% chance of being the Ramping Version. Whether a workflow falls into the\nRamping group depends on its Workflow ID and and the Ramp Percentage.\n\nThis behavior eliminates most of compatibility concerns users face when changing their code.\nPatching is not needed when pinned workflows code change.\nCan be overridden explicitly via `UpdateWorkflowExecutionOptions` API to move the\nexecution to another Deployment Version.\nActivities of `PINNED` workflows are sent to the same Deployment Version. Exception to this\nwould be when the activity Task Queue workers are not present in the workflow's Deployment\nVersion, in which case the activity will be sent to the Current Deployment Version of its own\ntask queue.\n - VERSIONING_BEHAVIOR_AUTO_UPGRADE: Workflow will automatically move to its Target Version when the next workflow task is dispatched.\n\nThe workflow's Target Version is the Current Version of its Task Queue, or, if the\nTask Queue has a Ramping Version with non-zero Ramp Percentage `P`, the workflow's Target\nVersion has a P% chance of being the Ramping Version. Whether a workflow falls into the\nRamping group depends on its Workflow ID and and the Ramp Percentage.\n\nAutoUpgrade behavior is suitable for long-running workflows as it allows them to move to the\nlatest Deployment Version, but the user still needs to use Patching to keep the new code\ncompatible with prior versions for changed workflow types.\nActivities of `AUTO_UPGRADE` workflows are sent to the Deployment Version of the workflow\nexecution (as specified in versioning_info.version based on the last completed\nworkflow task). Exception to this would be when the activity Task Queue workers are not\npresent in the workflow's Deployment Version, in which case, the activity will be sent to a\ndifferent Deployment Version according to the Current or Ramping Deployment Version of its own\nTask Queue.\nWorkflows stuck on a backlogged activity will still auto-upgrade if their Target Version\nchanges, without having to wait for the backlogged activity to complete on the old Version."
1738617411
},
1738717412
"v1VersioningOverride": {
1738817413
"type": "object",
1738917414
"properties": {
1739017415
"pinned": {
1739117416
"$ref": "#/definitions/VersioningOverridePinnedOverride",
17392-
"description": "Send the next workflow task to the Version specified in the override."
17417+
"description": "Override the workflow to have Pinned behavior."
1739317418
},
1739417419
"autoUpgrade": {
1739517420
"type": "boolean",
17396-
"description": "Send the next workflow task to the Current Deployment Version\nof its Task Queue when the next workflow task is dispatched."
17421+
"description": "Override the workflow to have AutoUpgrade behavior."
1739717422
},
1739817423
"behavior": {
1739917424
"$ref": "#/definitions/v1VersioningBehavior",
@@ -17408,7 +17433,7 @@
1740817433
"description": "Required if behavior is `PINNED`. Must be absent if behavior is not `PINNED`.\nIdentifies the worker deployment version to pin the workflow to, in the format\n\"<deployment_name>.<build_id>\".\nDeprecated. Use `override.pinned.version`."
1740917434
}
1741017435
},
17411-
"description": "Used to override the versioning behavior (and pinned deployment version, if applicable) of a\nspecific workflow execution. If set, takes precedence over the worker-sent values. See\n`WorkflowExecutionInfo.VersioningInfo` for more information. To remove the override, call\n`UpdateWorkflowExecutionOptions` with a null `VersioningOverride`, and use the `update_mask`\nto indicate that it should be mutated.\nPinned overrides are automatically inherited by child workflows, continue-as-new workflows,\nworkflow retries, and cron workflows."
17436+
"description": "Used to override the versioning behavior (and pinned deployment version, if applicable) of a\nspecific workflow execution. If set, this override takes precedence over worker-sent values.\nSee `WorkflowExecutionInfo.VersioningInfo` for more information.\n\nTo remove the override, call `UpdateWorkflowExecutionOptions` with a null\n`VersioningOverride`, and use the `update_mask` to indicate that it should be mutated.\n\nPinned behavior overrides are automatically inherited by child workflows, workflow retries, continue-as-new\nworkflows, and cron workflows."
1741217437
},
1741317438
"v1WaitPolicy": {
1741417439
"type": "object",
@@ -17985,6 +18010,10 @@
1798518010
"inheritBuildId": {
1798618011
"type": "boolean",
1798718012
"description": "If this is set, the new execution inherits the Build ID of the current execution. Otherwise,\nthe assignment rules will be used to independently assign a Build ID to the new execution.\nDeprecated. Only considered for versioning v0.2."
18013+
},
18014+
"initialVersioningBehavior": {
18015+
"$ref": "#/definitions/v1ContinueAsNewVersioningBehavior",
18016+
"description": "Experimental. Optionally decide the versioning behavior that the first task of the new run should use.\nFor example, choose to AutoUpgrade on continue-as-new instead of inheriting the pinned version\nof the previous run."
1798818017
}
1798918018
}
1799018019
},
@@ -18990,7 +19019,14 @@
1899019019
},
1899119020
"suggestContinueAsNew": {
1899219021
"type": "boolean",
18993-
"description": "True if this workflow should continue-as-new soon because its history size (in\neither event count or bytes) is getting large."
19022+
"description": "True if this workflow should continue-as-new soon. See `suggest_continue_as_new_reasons` for why."
19023+
},
19024+
"suggestContinueAsNewReasons": {
19025+
"type": "array",
19026+
"items": {
19027+
"$ref": "#/definitions/v1SuggestContinueAsNewReason"
19028+
},
19029+
"description": "The reason(s) that suggest_continue_as_new is true, if it is.\nUnset if suggest_continue_as_new is false."
1899419030
},
1899519031
"historySizeBytes": {
1899619032
"type": "string",

openapi/openapiv3.yaml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14531,12 +14531,10 @@ components:
1453114531
pinned:
1453214532
allOf:
1453314533
- $ref: '#/components/schemas/VersioningOverride_PinnedOverride'
14534-
description: Send the next workflow task to the Version specified in the override.
14534+
description: Override the workflow to have Pinned behavior.
1453514535
autoUpgrade:
1453614536
type: boolean
14537-
description: |-
14538-
Send the next workflow task to the Current Deployment Version
14539-
of its Task Queue when the next workflow task is dispatched.
14537+
description: Override the workflow to have AutoUpgrade behavior.
1454014538
behavior:
1454114539
enum:
1454214540
- VERSIONING_BEHAVIOR_UNSPECIFIED
@@ -14563,12 +14561,14 @@ components:
1456314561
Deprecated. Use `override.pinned.version`.
1456414562
description: |-
1456514563
Used to override the versioning behavior (and pinned deployment version, if applicable) of a
14566-
specific workflow execution. If set, takes precedence over the worker-sent values. See
14567-
`WorkflowExecutionInfo.VersioningInfo` for more information. To remove the override, call
14568-
`UpdateWorkflowExecutionOptions` with a null `VersioningOverride`, and use the `update_mask`
14569-
to indicate that it should be mutated.
14570-
Pinned overrides are automatically inherited by child workflows, continue-as-new workflows,
14571-
workflow retries, and cron workflows.
14564+
specific workflow execution. If set, this override takes precedence over worker-sent values.
14565+
See `WorkflowExecutionInfo.VersioningInfo` for more information.
14566+
14567+
To remove the override, call `UpdateWorkflowExecutionOptions` with a null
14568+
`VersioningOverride`, and use the `update_mask` to indicate that it should be mutated.
14569+
14570+
Pinned behavior overrides are automatically inherited by child workflows, workflow retries, continue-as-new
14571+
workflows, and cron workflows.
1457214572
VersioningOverride_PinnedOverride:
1457314573
type: object
1457414574
properties:
@@ -15392,6 +15392,16 @@ components:
1539215392
If this is set, the new execution inherits the Build ID of the current execution. Otherwise,
1539315393
the assignment rules will be used to independently assign a Build ID to the new execution.
1539415394
Deprecated. Only considered for versioning v0.2.
15395+
initialVersioningBehavior:
15396+
enum:
15397+
- CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_UNSPECIFIED
15398+
- CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_AUTO_UPGRADE
15399+
type: string
15400+
description: |-
15401+
Experimental. Optionally decide the versioning behavior that the first task of the new run should use.
15402+
For example, choose to AutoUpgrade on continue-as-new instead of inheriting the pinned version
15403+
of the previous run.
15404+
format: enum
1539515405
WorkflowExecutionExtendedInfo:
1539615406
type: object
1539715407
properties:
@@ -16510,9 +16520,21 @@ components:
1651016520
service would return AlreadyStarted error, and matching would drop the task.
1651116521
suggestContinueAsNew:
1651216522
type: boolean
16523+
description: True if this workflow should continue-as-new soon. See `suggest_continue_as_new_reasons` for why.
16524+
suggestContinueAsNewReasons:
16525+
type: array
16526+
items:
16527+
enum:
16528+
- SUGGEST_CONTINUE_AS_NEW_REASON_UNSPECIFIED
16529+
- SUGGEST_CONTINUE_AS_NEW_REASON_HISTORY_SIZE_TOO_LARGE
16530+
- SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_HISTORY_EVENTS
16531+
- SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_UPDATES
16532+
- SUGGEST_CONTINUE_AS_NEW_REASON_TARGET_WORKER_DEPLOYMENT_VERSION_CHANGED
16533+
type: string
16534+
format: enum
1651316535
description: |-
16514-
True if this workflow should continue-as-new soon because its history size (in
16515-
either event count or bytes) is getting large.
16536+
The reason(s) that suggest_continue_as_new is true, if it is.
16537+
Unset if suggest_continue_as_new is false.
1651616538
historySizeBytes:
1651716539
type: string
1651816540
description: |-

temporal/api/command/v1/message.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ message ContinueAsNewWorkflowExecutionCommandAttributes {
179179
// Deprecated. Only considered for versioning v0.2.
180180
bool inherit_build_id = 15 [deprecated = true];
181181

182+
// Experimental. Optionally decide the versioning behavior that the first task of the new run should use.
183+
// For example, choose to AutoUpgrade on continue-as-new instead of inheriting the pinned version
184+
// of the previous run.
185+
temporal.api.enums.v1.ContinueAsNewVersioningBehavior initial_versioning_behavior = 16;
186+
182187
// `workflow_execution_timeout` is omitted as it shouldn't be overridden from within a workflow.
183188
}
184189

0 commit comments

Comments
 (0)