@temporalio/core-bridge 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +83 -98
- package/lib/index.d.ts +8 -6
- package/lib/index.js.map +1 -1
- package/package.json +8 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.buildkite/docker/Dockerfile +2 -2
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.buildkite/pipeline.yml +1 -1
- package/sdk-core/.github/workflows/heavy.yml +1 -0
- package/sdk-core/README.md +13 -7
- package/sdk-core/client/src/lib.rs +4 -3
- package/sdk-core/client/src/metrics.rs +17 -8
- package/sdk-core/client/src/raw.rs +3 -3
- package/sdk-core/core/Cargo.toml +3 -4
- package/sdk-core/core/src/abstractions/take_cell.rs +28 -0
- package/sdk-core/core/src/abstractions.rs +197 -18
- package/sdk-core/core/src/core_tests/activity_tasks.rs +137 -45
- package/sdk-core/core/src/core_tests/child_workflows.rs +6 -5
- package/sdk-core/core/src/core_tests/determinism.rs +165 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +183 -36
- package/sdk-core/core/src/core_tests/queries.rs +32 -14
- package/sdk-core/core/src/core_tests/workers.rs +8 -5
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +340 -51
- package/sdk-core/core/src/ephemeral_server/mod.rs +110 -8
- package/sdk-core/core/src/internal_flags.rs +155 -0
- package/sdk-core/core/src/lib.rs +14 -9
- package/sdk-core/core/src/replay/mod.rs +16 -27
- package/sdk-core/core/src/telemetry/metrics.rs +69 -35
- package/sdk-core/core/src/telemetry/mod.rs +38 -14
- package/sdk-core/core/src/telemetry/prometheus_server.rs +19 -13
- package/sdk-core/core/src/test_help/mod.rs +65 -13
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +119 -160
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- package/sdk-core/core/src/worker/activities/local_activities.rs +122 -6
- package/sdk-core/core/src/worker/activities.rs +347 -173
- package/sdk-core/core/src/worker/client/mocks.rs +22 -2
- package/sdk-core/core/src/worker/client.rs +18 -2
- package/sdk-core/core/src/worker/mod.rs +136 -44
- package/sdk-core/core/src/worker/workflow/history_update.rs +132 -51
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +207 -166
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +157 -82
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +12 -12
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +13 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +170 -60
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +24 -16
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +6 -8
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +320 -204
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +10 -13
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +15 -23
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +256 -50
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +240 -111
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -13
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +10 -6
- package/sdk-core/core/src/worker/workflow/managed_run.rs +71 -60
- package/sdk-core/core/src/worker/workflow/mod.rs +321 -73
- package/sdk-core/core/src/worker/workflow/run_cache.rs +18 -11
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +15 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +2 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +46 -25
- package/sdk-core/core-api/Cargo.toml +0 -1
- package/sdk-core/core-api/src/lib.rs +13 -7
- package/sdk-core/core-api/src/telemetry.rs +4 -6
- package/sdk-core/core-api/src/worker.rs +5 -0
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +80 -55
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +22 -68
- package/sdk-core/histories/ends_empty_wft_complete.bin +0 -0
- package/sdk-core/histories/old_change_marker_format.bin +0 -0
- package/sdk-core/protos/api_upstream/.github/CODEOWNERS +2 -1
- package/sdk-core/protos/api_upstream/Makefile +1 -1
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +5 -17
- package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +11 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +1 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +5 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +22 -6
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +48 -19
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -0
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/{enums/v1/interaction_type.proto → protocol/v1/message.proto} +29 -11
- package/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +111 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +59 -28
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +2 -2
- package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +7 -8
- package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +10 -7
- package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +19 -30
- package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +8 -0
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +65 -60
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +85 -84
- package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +9 -3
- package/sdk-core/sdk/Cargo.toml +1 -1
- package/sdk-core/sdk/src/lib.rs +21 -5
- package/sdk-core/sdk/src/workflow_context/options.rs +7 -1
- package/sdk-core/sdk/src/workflow_context.rs +24 -17
- package/sdk-core/sdk/src/workflow_future.rs +9 -3
- package/sdk-core/sdk-core-protos/src/history_builder.rs +114 -89
- package/sdk-core/sdk-core-protos/src/history_info.rs +6 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +205 -64
- package/sdk-core/test-utils/src/canned_histories.rs +106 -296
- package/sdk-core/test-utils/src/lib.rs +32 -5
- package/sdk-core/tests/heavy_tests.rs +10 -43
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -3
- package/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
- package/sdk-core/tests/integ_tests/polling_tests.rs +3 -8
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -2
- package/sdk-core/tests/integ_tests/visibility_tests.rs +34 -23
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +97 -81
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +80 -3
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +5 -1
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +25 -3
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +2 -4
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +30 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +64 -0
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +4 -0
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +3 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +7 -2
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +8 -8
- package/sdk-core/tests/main.rs +1 -1
- package/sdk-core/tests/runner.rs +11 -9
- package/src/conversions.rs +14 -8
- package/src/runtime.rs +9 -8
- package/ts/index.ts +8 -6
- package/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +0 -87
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
use super::{
|
|
4
4
|
workflow_machines::MachineResponse, Cancellable, EventInfo, WFMachinesAdapter, WFMachinesError,
|
|
5
5
|
};
|
|
6
|
-
use
|
|
6
|
+
use crate::worker::workflow::machines::HistEventData;
|
|
7
|
+
use rustfsm::{fsm, StateMachine, TransitionResult};
|
|
7
8
|
use std::{
|
|
8
9
|
convert::{TryFrom, TryInto},
|
|
9
10
|
time::SystemTime,
|
|
@@ -31,12 +32,12 @@ fsm! {
|
|
|
31
32
|
|
|
32
33
|
impl WorkflowTaskMachine {
|
|
33
34
|
pub(super) fn new(wf_task_started_event_id: i64) -> Self {
|
|
34
|
-
Self
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
Self::from_parts(
|
|
36
|
+
Created {}.into(),
|
|
37
|
+
SharedState {
|
|
37
38
|
wf_task_started_event_id,
|
|
38
39
|
},
|
|
39
|
-
|
|
40
|
+
)
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -63,8 +64,8 @@ impl WFMachinesAdapter for WorkflowTaskMachine {
|
|
|
63
64
|
task_started_event_id,
|
|
64
65
|
time,
|
|
65
66
|
} => {
|
|
66
|
-
let (event_id, event_type
|
|
67
|
-
(ei.event_id, ei.event_type
|
|
67
|
+
let (event_id, event_type) = if let Some(ei) = event_info {
|
|
68
|
+
(ei.event_id, ei.event_type)
|
|
68
69
|
} else {
|
|
69
70
|
return Err(WFMachinesError::Fatal(
|
|
70
71
|
"WF Task machine should never issue a task started trigger \
|
|
@@ -74,9 +75,7 @@ impl WFMachinesAdapter for WorkflowTaskMachine {
|
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
let cur_event_past_or_at_start = event_id >= task_started_event_id;
|
|
77
|
-
if event_type == EventType::WorkflowTaskStarted
|
|
78
|
-
&& (!cur_event_past_or_at_start || has_next_event)
|
|
79
|
-
{
|
|
78
|
+
if event_type == EventType::WorkflowTaskStarted && !cur_event_past_or_at_start {
|
|
80
79
|
return Ok(vec![]);
|
|
81
80
|
}
|
|
82
81
|
Ok(vec![MachineResponse::TriggerWFTaskStarted {
|
|
@@ -102,10 +101,11 @@ impl WFMachinesAdapter for WorkflowTaskMachine {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
impl TryFrom<
|
|
104
|
+
impl TryFrom<HistEventData> for WorkflowTaskMachineEvents {
|
|
106
105
|
type Error = WFMachinesError;
|
|
107
106
|
|
|
108
|
-
fn try_from(e:
|
|
107
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
|
108
|
+
let e = e.event;
|
|
109
109
|
Ok(match e.event_type() {
|
|
110
110
|
EventType::WorkflowTaskScheduled => Self::WorkflowTaskScheduled,
|
|
111
111
|
EventType::WorkflowTaskStarted => Self::WorkflowTaskStarted({
|
|
@@ -201,7 +201,7 @@ pub(super) struct WFTFailedDat {
|
|
|
201
201
|
impl Scheduled {
|
|
202
202
|
pub(super) fn on_workflow_task_started(
|
|
203
203
|
self,
|
|
204
|
-
shared: SharedState,
|
|
204
|
+
shared: &mut SharedState,
|
|
205
205
|
WFTStartedDat {
|
|
206
206
|
current_time_millis,
|
|
207
207
|
started_event_id,
|
|
@@ -3,6 +3,7 @@ use crate::{
|
|
|
3
3
|
replay::TestHistoryBuilder,
|
|
4
4
|
test_help::TEST_Q,
|
|
5
5
|
worker::{
|
|
6
|
+
client::mocks::DEFAULT_TEST_CAPABILITIES,
|
|
6
7
|
workflow::{
|
|
7
8
|
history_update::tests::TestHBExt, machines::WorkflowMachines, WFCommand,
|
|
8
9
|
WorkflowFetcher,
|
|
@@ -87,13 +88,16 @@ impl ManagedWFFunc {
|
|
|
87
88
|
completions_q: completions_sync_rx,
|
|
88
89
|
};
|
|
89
90
|
let state_machines = WorkflowMachines::new(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
RunBasics {
|
|
92
|
+
namespace: "test_namespace".to_string(),
|
|
93
|
+
workflow_id: "wfid".to_string(),
|
|
94
|
+
workflow_type: "wftype".to_string(),
|
|
95
|
+
run_id: "runid".to_string(),
|
|
96
|
+
history: hist,
|
|
97
|
+
metrics: MetricsContext::no_op(),
|
|
98
|
+
capabilities: &DEFAULT_TEST_CAPABILITIES,
|
|
99
|
+
},
|
|
95
100
|
Box::new(driver).into(),
|
|
96
|
-
MetricsContext::no_op(),
|
|
97
101
|
);
|
|
98
102
|
let mgr = WorkflowManager::new_from_machines(state_machines);
|
|
99
103
|
Self {
|
|
@@ -13,7 +13,7 @@ use crate::{
|
|
|
13
13
|
ActivationCompleteOutcome, ActivationCompleteResult, ActivationOrAuto,
|
|
14
14
|
EvictionRequestResult, FailedActivationWFTReport, HeartbeatTimeoutMsg, HistoryUpdate,
|
|
15
15
|
LocalActivityRequestSink, LocalResolution, NextPageReq, OutgoingServerCommands,
|
|
16
|
-
OutstandingActivation, OutstandingTask, PermittedWFT, RequestEvictMsg,
|
|
16
|
+
OutstandingActivation, OutstandingTask, PermittedWFT, RequestEvictMsg, RunBasics,
|
|
17
17
|
ServerCommandsWithWorkflowInfo, WFCommand, WFMachinesError, WFTReportStatus,
|
|
18
18
|
WorkflowBridge, WorkflowTaskInfo, WFT_HEARTBEAT_TIMEOUT_FRACTION,
|
|
19
19
|
},
|
|
@@ -25,7 +25,8 @@ use futures_util::future::AbortHandle;
|
|
|
25
25
|
use std::{
|
|
26
26
|
collections::HashSet,
|
|
27
27
|
ops::Add,
|
|
28
|
-
|
|
28
|
+
rc::Rc,
|
|
29
|
+
sync::mpsc::Sender,
|
|
29
30
|
time::{Duration, Instant},
|
|
30
31
|
};
|
|
31
32
|
use temporal_sdk_core_protos::{
|
|
@@ -65,7 +66,7 @@ pub(super) struct ManagedRun {
|
|
|
65
66
|
/// pushing things out and then directly back in. The downside is this is the only "impure" part
|
|
66
67
|
/// of the in/out nature of workflow state management. If there's ever a sensible way to lift it
|
|
67
68
|
/// up, that'd be nice.
|
|
68
|
-
local_activity_request_sink:
|
|
69
|
+
local_activity_request_sink: Rc<dyn LocalActivityRequestSink>,
|
|
69
70
|
/// Set if the run is currently waiting on the execution of some local activities.
|
|
70
71
|
waiting_on_la: Option<WaitingOnLAs>,
|
|
71
72
|
/// Is set to true if the machines encounter an error and the only subsequent thing we should
|
|
@@ -93,24 +94,12 @@ pub(super) struct ManagedRun {
|
|
|
93
94
|
completion_waiting_on_page_fetch: Option<RunActivationCompletion>,
|
|
94
95
|
}
|
|
95
96
|
impl ManagedRun {
|
|
96
|
-
#[allow(clippy::too_many_arguments)] // Ok with this here. Nothing reusable to extract.
|
|
97
97
|
pub(super) fn new(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
workflow_id: String,
|
|
101
|
-
workflow_type: String,
|
|
102
|
-
run_id: String,
|
|
103
|
-
local_activity_request_sink: Arc<dyn LocalActivityRequestSink>,
|
|
104
|
-
metrics: MetricsContext,
|
|
98
|
+
basics: RunBasics,
|
|
99
|
+
local_activity_request_sink: Rc<dyn LocalActivityRequestSink>,
|
|
105
100
|
) -> Self {
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
namespace,
|
|
109
|
-
workflow_id,
|
|
110
|
-
workflow_type,
|
|
111
|
-
run_id,
|
|
112
|
-
metrics.clone(),
|
|
113
|
-
);
|
|
101
|
+
let metrics = basics.metrics.clone();
|
|
102
|
+
let wfm = WorkflowManager::new(basics);
|
|
114
103
|
Self {
|
|
115
104
|
wfm,
|
|
116
105
|
local_activity_request_sink,
|
|
@@ -283,6 +272,10 @@ impl ManagedRun {
|
|
|
283
272
|
if let Some(ot) = &retme {
|
|
284
273
|
self.metrics.wf_task_latency(ot.start_time.elapsed());
|
|
285
274
|
}
|
|
275
|
+
// Tell the LA manager that we're done with the WFT
|
|
276
|
+
self.local_activity_request_sink.sink_reqs(vec![
|
|
277
|
+
LocalActRequest::IndicateWorkflowTaskCompleted(self.wfm.machines.run_id.clone()),
|
|
278
|
+
]);
|
|
286
279
|
}
|
|
287
280
|
|
|
288
281
|
retme
|
|
@@ -354,6 +347,7 @@ impl ManagedRun {
|
|
|
354
347
|
pub(super) fn successful_completion(
|
|
355
348
|
&mut self,
|
|
356
349
|
mut commands: Vec<WFCommand>,
|
|
350
|
+
used_flags: Vec<u32>,
|
|
357
351
|
resp_chan: Option<oneshot::Sender<ActivationCompleteResult>>,
|
|
358
352
|
) -> Result<RunUpdateAct, NextPageReq> {
|
|
359
353
|
let activation_was_only_eviction = self.activation_has_only_eviction();
|
|
@@ -372,7 +366,20 @@ impl ManagedRun {
|
|
|
372
366
|
self.run_id()
|
|
373
367
|
);
|
|
374
368
|
}
|
|
375
|
-
self.
|
|
369
|
+
let outcome = if let Some((tt, reason)) = self.trying_to_evict.as_mut().and_then(|te| {
|
|
370
|
+
te.auto_reply_fail_tt
|
|
371
|
+
.take()
|
|
372
|
+
.map(|tt| (tt, te.message.clone()))
|
|
373
|
+
}) {
|
|
374
|
+
ActivationCompleteOutcome::ReportWFTFail(FailedActivationWFTReport::Report(
|
|
375
|
+
tt,
|
|
376
|
+
WorkflowTaskFailedCause::Unspecified,
|
|
377
|
+
Failure::application_failure(reason, true).into(),
|
|
378
|
+
))
|
|
379
|
+
} else {
|
|
380
|
+
ActivationCompleteOutcome::DoNothing
|
|
381
|
+
};
|
|
382
|
+
self.reply_to_complete(outcome, resp_chan);
|
|
376
383
|
return Ok(None);
|
|
377
384
|
};
|
|
378
385
|
|
|
@@ -422,6 +429,7 @@ impl ManagedRun {
|
|
|
422
429
|
activation_was_only_eviction,
|
|
423
430
|
has_pending_query,
|
|
424
431
|
query_responses,
|
|
432
|
+
used_flags,
|
|
425
433
|
resp_chan,
|
|
426
434
|
};
|
|
427
435
|
|
|
@@ -516,6 +524,7 @@ impl ManagedRun {
|
|
|
516
524
|
run_id: self.run_id().to_string(),
|
|
517
525
|
message,
|
|
518
526
|
reason,
|
|
527
|
+
auto_reply_fail_tt: None,
|
|
519
528
|
});
|
|
520
529
|
let should_report = match &evict_req_outcome {
|
|
521
530
|
EvictionRequestResult::EvictionRequested(Some(attempt), _)
|
|
@@ -568,6 +577,8 @@ impl ManagedRun {
|
|
|
568
577
|
activation_was_only_eviction: completion.activation_was_only_eviction,
|
|
569
578
|
};
|
|
570
579
|
|
|
580
|
+
self.wfm.machines.add_lang_used_flags(completion.used_flags);
|
|
581
|
+
|
|
571
582
|
// If this is just bookkeeping after a reply to an only-eviction activation, we can bypass
|
|
572
583
|
// everything, since there is no reason to continue trying to update machines.
|
|
573
584
|
if completion.activation_was_only_eviction {
|
|
@@ -688,9 +699,6 @@ impl ManagedRun {
|
|
|
688
699
|
// Auto-reply WFT complete
|
|
689
700
|
return true;
|
|
690
701
|
}
|
|
691
|
-
} else {
|
|
692
|
-
// If a heartbeat timeout happened, we should always have been waiting on LAs
|
|
693
|
-
dbg_panic!("WFT heartbeat timeout fired but we were not waiting on any LAs");
|
|
694
702
|
}
|
|
695
703
|
false
|
|
696
704
|
}
|
|
@@ -776,6 +784,8 @@ impl ManagedRun {
|
|
|
776
784
|
self.trying_to_evict = Some(info);
|
|
777
785
|
EvictionRequestResult::EvictionRequested(attempts, self.check_more_activations())
|
|
778
786
|
} else {
|
|
787
|
+
// Always store the most recent eviction reason
|
|
788
|
+
self.trying_to_evict = Some(info);
|
|
779
789
|
EvictionRequestResult::EvictionAlreadyRequested(attempts)
|
|
780
790
|
}
|
|
781
791
|
}
|
|
@@ -844,7 +854,9 @@ impl ManagedRun {
|
|
|
844
854
|
None
|
|
845
855
|
}
|
|
846
856
|
}
|
|
847
|
-
a @ Some(
|
|
857
|
+
a @ Some(
|
|
858
|
+
ActivationOrAuto::Autocomplete { .. } | ActivationOrAuto::AutoFail { .. },
|
|
859
|
+
) => a,
|
|
848
860
|
None => {
|
|
849
861
|
if let Some(reason) = self.trying_to_evict.as_ref() {
|
|
850
862
|
// If we had nothing to do, but we're trying to evict, just do that now
|
|
@@ -906,12 +918,10 @@ impl ManagedRun {
|
|
|
906
918
|
)
|
|
907
919
|
} else {
|
|
908
920
|
warn!(error=?fail.source, "Error while updating workflow");
|
|
909
|
-
|
|
910
|
-
run_id: self.run_id().
|
|
911
|
-
|
|
912
|
-
reason: fail.source.evict_reason(),
|
|
921
|
+
Some(ActivationOrAuto::AutoFail {
|
|
922
|
+
run_id: self.run_id().to_owned(),
|
|
923
|
+
machines_err: fail.source,
|
|
913
924
|
})
|
|
914
|
-
.into_run_update_resp()
|
|
915
925
|
};
|
|
916
926
|
rur
|
|
917
927
|
}
|
|
@@ -930,7 +940,9 @@ impl ManagedRun {
|
|
|
930
940
|
}
|
|
931
941
|
}
|
|
932
942
|
}
|
|
933
|
-
ActivationOrAuto::Autocomplete { .. } =>
|
|
943
|
+
ActivationOrAuto::Autocomplete { .. } | ActivationOrAuto::AutoFail { .. } => {
|
|
944
|
+
OutstandingActivation::Autocomplete
|
|
945
|
+
}
|
|
934
946
|
};
|
|
935
947
|
if let Some(old_act) = self.activation {
|
|
936
948
|
// This is a panic because we have screwed up core logic if this is violated. It must be
|
|
@@ -949,12 +961,18 @@ impl ManagedRun {
|
|
|
949
961
|
data: CompletionDataForWFT,
|
|
950
962
|
due_to_heartbeat_timeout: bool,
|
|
951
963
|
) -> FulfillableActivationComplete {
|
|
952
|
-
let outgoing_cmds = self.wfm.get_server_commands();
|
|
964
|
+
let mut outgoing_cmds = self.wfm.get_server_commands();
|
|
953
965
|
if data.activation_was_only_eviction && !outgoing_cmds.commands.is_empty() {
|
|
954
|
-
|
|
966
|
+
if self.am_broken {
|
|
967
|
+
// If we broke there could be commands in the pipe that we didn't get a chance to
|
|
968
|
+
// handle properly during replay, just wipe them all out.
|
|
969
|
+
outgoing_cmds.commands = vec![];
|
|
970
|
+
} else {
|
|
971
|
+
dbg_panic!(
|
|
955
972
|
"There should not be any outgoing commands when preparing a completion response \
|
|
956
973
|
if the activation was only an eviction. This is an SDK bug."
|
|
957
|
-
|
|
974
|
+
);
|
|
975
|
+
}
|
|
958
976
|
}
|
|
959
977
|
|
|
960
978
|
let query_responses = data.query_responses;
|
|
@@ -970,7 +988,8 @@ impl ManagedRun {
|
|
|
970
988
|
let should_respond = !(self.wfm.machines.has_pending_jobs()
|
|
971
989
|
|| outgoing_cmds.replaying
|
|
972
990
|
|| is_query_playback
|
|
973
|
-
|| data.activation_was_only_eviction
|
|
991
|
+
|| data.activation_was_only_eviction
|
|
992
|
+
|| self.wfm.machines.have_seen_terminal_event);
|
|
974
993
|
// If there are pending LA resolutions, and we're responding to a query here,
|
|
975
994
|
// we want to make sure to force a new task, as otherwise once we tell lang about
|
|
976
995
|
// the LA resolution there wouldn't be any task to reply to with the result of iterating
|
|
@@ -986,16 +1005,14 @@ impl ManagedRun {
|
|
|
986
1005
|
force_new_wft,
|
|
987
1006
|
commands: outgoing_cmds.commands,
|
|
988
1007
|
query_responses,
|
|
1008
|
+
sdk_metadata: self.wfm.machines.get_metadata_for_wft_complete(),
|
|
989
1009
|
},
|
|
990
1010
|
})
|
|
991
1011
|
} else {
|
|
992
1012
|
ActivationCompleteOutcome::DoNothing
|
|
993
1013
|
};
|
|
994
1014
|
FulfillableActivationComplete {
|
|
995
|
-
result:
|
|
996
|
-
most_recently_processed_event: self.wfm.machines.last_processed_event as usize,
|
|
997
|
-
outcome,
|
|
998
|
-
},
|
|
1015
|
+
result: self.build_activation_complete_result(outcome),
|
|
999
1016
|
resp_chan,
|
|
1000
1017
|
}
|
|
1001
1018
|
}
|
|
@@ -1023,11 +1040,19 @@ impl ManagedRun {
|
|
|
1023
1040
|
chan: Option<oneshot::Sender<ActivationCompleteResult>>,
|
|
1024
1041
|
) {
|
|
1025
1042
|
if let Some(chan) = chan {
|
|
1026
|
-
chan.send(
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1043
|
+
chan.send(self.build_activation_complete_result(outcome))
|
|
1044
|
+
.expect("Rcv half of activation reply not dropped");
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
fn build_activation_complete_result(
|
|
1049
|
+
&self,
|
|
1050
|
+
outcome: ActivationCompleteOutcome,
|
|
1051
|
+
) -> ActivationCompleteResult {
|
|
1052
|
+
ActivationCompleteResult {
|
|
1053
|
+
outcome,
|
|
1054
|
+
most_recently_processed_event: self.most_recently_processed_event_number() as usize,
|
|
1055
|
+
replaying: self.wfm.machines.replaying,
|
|
1031
1056
|
}
|
|
1032
1057
|
}
|
|
1033
1058
|
|
|
@@ -1139,24 +1164,9 @@ struct WorkflowManager {
|
|
|
1139
1164
|
impl WorkflowManager {
|
|
1140
1165
|
/// Create a new workflow manager given workflow history and execution info as would be found
|
|
1141
1166
|
/// in [PollWorkflowTaskQueueResponse]
|
|
1142
|
-
fn new(
|
|
1143
|
-
history: HistoryUpdate,
|
|
1144
|
-
namespace: String,
|
|
1145
|
-
workflow_id: String,
|
|
1146
|
-
workflow_type: String,
|
|
1147
|
-
run_id: String,
|
|
1148
|
-
metrics: MetricsContext,
|
|
1149
|
-
) -> Self {
|
|
1167
|
+
fn new(basics: RunBasics) -> Self {
|
|
1150
1168
|
let (wfb, cmd_sink) = WorkflowBridge::new();
|
|
1151
|
-
let state_machines = WorkflowMachines::new(
|
|
1152
|
-
namespace,
|
|
1153
|
-
workflow_id,
|
|
1154
|
-
workflow_type,
|
|
1155
|
-
run_id,
|
|
1156
|
-
history,
|
|
1157
|
-
Box::new(wfb).into(),
|
|
1158
|
-
metrics,
|
|
1159
|
-
);
|
|
1169
|
+
let state_machines = WorkflowMachines::new(basics, Box::new(wfb).into());
|
|
1160
1170
|
Self {
|
|
1161
1171
|
machines: state_machines,
|
|
1162
1172
|
command_sink: Some(cmd_sink),
|
|
@@ -1289,6 +1299,7 @@ struct RunActivationCompletion {
|
|
|
1289
1299
|
activation_was_only_eviction: bool,
|
|
1290
1300
|
has_pending_query: bool,
|
|
1291
1301
|
query_responses: Vec<QueryResult>,
|
|
1302
|
+
used_flags: Vec<u32>,
|
|
1292
1303
|
/// Used to notify the worker when the completion is done processing and the completion can
|
|
1293
1304
|
/// unblock. Must always be `Some` when initialized.
|
|
1294
1305
|
resp_chan: Option<oneshot::Sender<ActivationCompleteResult>>,
|