Skip to content

Commit caad11a

Browse files
authored
Updates for update reapply (#677)
* Update protos from temporalio/api#351 rsync -auv ../api/temporal/ sdk-core-protos/protos/api_upstream/temporal/ * Ignore UpdateRequested event
1 parent 42e2a94 commit caad11a

File tree

7 files changed

+50
-5
lines changed

7 files changed

+50
-5
lines changed

core/src/worker/workflow/machines/workflow_machines.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,10 @@ impl WorkflowMachines {
781781
Ok(EventHandlingOutcome::Normal)
782782
};
783783
}
784-
if event.event_type() == EventType::Unspecified || event.attributes.is_none() {
784+
if event.event_type() == EventType::Unspecified
785+
|| event.event_type() == EventType::WorkflowExecutionUpdateRequested
786+
|| event.attributes.is_none()
787+
{
785788
return if !event.worker_may_ignore {
786789
Err(WFMachinesError::Fatal(format!(
787790
"Event type is unspecified! This history is invalid. Event detail: {event:?}"

sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,8 @@ enum EventType {
167167
EVENT_TYPE_ACTIVITY_PROPERTIES_MODIFIED_EXTERNALLY = 45;
168168
// Workflow properties modified by user workflow code
169169
EVENT_TYPE_WORKFLOW_PROPERTIES_MODIFIED = 46;
170+
// An update was requested. Note that not all update requests result in this
171+
// event. See UpdateRequestedEventOrigin for situations in which this event
172+
// is created.
173+
EVENT_TYPE_WORKFLOW_EXECUTION_UPDATE_REQUESTED = 47;
170174
}

sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,26 @@ option java_outer_classname = "ResetProto";
3131
option ruby_package = "Temporalio::Api::Enums::V1";
3232
option csharp_namespace = "Temporalio.Api.Enums.V1";
3333

34-
// Reset reapply (replay) options
35-
// * RESET_REAPPLY_TYPE_SIGNAL (default) - Signals are reapplied when workflow is reset
36-
// * RESET_REAPPLY_TYPE_NONE - nothing is reapplied
34+
// Event types to exclude when reapplying events.
35+
enum ResetReapplyExcludeType {
36+
RESET_REAPPLY_EXCLUDE_TYPE_UNSPECIFIED = 0;
37+
// Exclude signals when reapplying events.
38+
RESET_REAPPLY_EXCLUDE_TYPE_SIGNAL = 1;
39+
// Exclude updates when reapplying events.
40+
RESET_REAPPLY_EXCLUDE_TYPE_UPDATE = 2;
41+
}
42+
43+
// Event types to include when reapplying events. Deprecated: applications
44+
// should use ResetReapplyExcludeType to specify exclusions from this set, and
45+
// new event types should be added to ResetReapplyExcludeType instead of here.
3746
enum ResetReapplyType {
3847
RESET_REAPPLY_TYPE_UNSPECIFIED = 0;
48+
// Signals are reapplied when workflow is reset.
3949
RESET_REAPPLY_TYPE_SIGNAL = 1;
50+
// No events are reapplied when workflow is reset.
4051
RESET_REAPPLY_TYPE_NONE = 2;
52+
// All eligible events are reapplied when workflow is reset.
53+
RESET_REAPPLY_TYPE_ALL_ELIGIBLE = 3;
4154
}
4255

4356
// Reset type options. Deprecated, see temporal.api.common.v1.ResetOptions.

sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,14 @@ enum UpdateWorkflowExecutionLifecycleStage {
5454
// on a worker and has either been rejected or returned a value or an error.
5555
UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED = 3;
5656
}
57+
58+
// UpdateRequestedEventOrigin records why an
59+
// WorkflowExecutionUpdateRequestedEvent was written to history. Note that not
60+
// all update requests result in a WorkflowExecutionUpdateRequestedEvent.
61+
enum UpdateRequestedEventOrigin {
62+
UPDATE_REQUESTED_EVENT_ORIGIN_UNSPECIFIED = 0;
63+
// The UpdateRequested event was created when reapplying events during reset
64+
// or replication. I.e. an accepted update on one branch of workflow history
65+
// was converted into a requested update on a different branch.
66+
UPDATE_REQUESTED_EVENT_ORIGIN_REAPPLY = 1;
67+
}

sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import "google/protobuf/timestamp.proto";
3636

3737
import "temporal/api/enums/v1/event_type.proto";
3838
import "temporal/api/enums/v1/failed_cause.proto";
39+
import "temporal/api/enums/v1/update.proto";
3940
import "temporal/api/enums/v1/workflow.proto";
4041
import "temporal/api/common/v1/message.proto";
4142
import "temporal/api/failure/v1/message.proto";
@@ -434,6 +435,8 @@ message WorkflowExecutionSignaledEventAttributes {
434435
temporal.api.common.v1.Header header = 4;
435436
// Indicates the signal did not generate a new workflow task when received.
436437
bool skip_generate_workflow_task = 5;
438+
// When signal origin is a workflow execution, this field is set.
439+
temporal.api.common.v1.WorkflowExecution external_workflow_execution = 6;
437440
}
438441

439442
message WorkflowExecutionTerminatedEventAttributes {
@@ -747,6 +750,12 @@ message WorkflowExecutionUpdateRejectedEventAttributes {
747750
temporal.api.failure.v1.Failure failure = 5;
748751
}
749752

753+
message WorkflowExecutionUpdateRequestedEventAttributes {
754+
// The update request associated with this event.
755+
temporal.api.update.v1.Request request = 1;
756+
// A record of why this event was written to history.
757+
temporal.api.enums.v1.UpdateRequestedEventOrigin origin = 2;
758+
}
750759

751760
// History events are the method by which Temporal SDKs advance (or recreate) workflow state.
752761
// See the `EventType` enum for more info about what each event is for.
@@ -812,6 +821,7 @@ message HistoryEvent {
812821
WorkflowPropertiesModifiedExternallyEventAttributes workflow_properties_modified_externally_event_attributes = 49;
813822
ActivityPropertiesModifiedExternallyEventAttributes activity_properties_modified_externally_event_attributes = 50;
814823
WorkflowPropertiesModifiedEventAttributes workflow_properties_modified_event_attributes = 51;
824+
WorkflowExecutionUpdateRequestedEventAttributes workflow_execution_update_requested_event_attributes = 52;
815825
}
816826
}
817827

sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,11 @@ message ResetWorkflowExecutionRequest {
669669
int64 workflow_task_finish_event_id = 4;
670670
// Used to de-dupe reset requests
671671
string request_id = 5;
672-
// Reset reapply (replay) options.
672+
// Event types to be reapplied (deprecated)
673+
// Default: RESET_REAPPLY_TYPE_ALL_ELIGIBLE
673674
temporal.api.enums.v1.ResetReapplyType reset_reapply_type = 6;
675+
// Event types not to be reapplied
676+
repeated temporal.api.enums.v1.ResetReapplyExcludeType reset_reapply_exclude_types = 7;
674677
}
675678

676679
message ResetWorkflowExecutionResponse {

sdk-core-protos/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,7 @@ pub mod temporal {
19811981
Attributes::WorkflowExecutionUpdateRejectedEventAttributes(_) => {EventType::WorkflowExecutionUpdateRejected}
19821982
Attributes::WorkflowExecutionUpdateAcceptedEventAttributes(_) => {EventType::WorkflowExecutionUpdateAccepted}
19831983
Attributes::WorkflowExecutionUpdateCompletedEventAttributes(_) => {EventType::WorkflowExecutionUpdateCompleted}
1984+
Attributes::WorkflowExecutionUpdateRequestedEventAttributes(_) => {EventType::WorkflowExecutionUpdateRequested}
19841985
Attributes::WorkflowPropertiesModifiedExternallyEventAttributes(_) => {EventType::WorkflowPropertiesModifiedExternally}
19851986
Attributes::ActivityPropertiesModifiedExternallyEventAttributes(_) => {EventType::ActivityPropertiesModifiedExternally}
19861987
Attributes::WorkflowPropertiesModifiedEventAttributes(_) => {EventType::WorkflowPropertiesModified}

0 commit comments

Comments
 (0)