@temporalio/core-bridge 1.11.8 → 1.12.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 +219 -193
- package/Cargo.toml +27 -8
- package/README.md +5 -0
- package/index.js +72 -12
- package/lib/errors.d.ts +25 -0
- package/lib/errors.js +76 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +11 -478
- package/lib/index.js +28 -5
- package/lib/index.js.map +1 -1
- package/lib/native.d.ts +330 -0
- package/lib/{worker-tuner.js → native.js} +1 -1
- package/lib/native.js.map +1 -0
- package/package.json +7 -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/.cargo/config.toml +8 -2
- package/sdk-core/.cargo/multi-worker-manual-test +15 -0
- package/sdk-core/.github/workflows/per-pr.yml +40 -11
- package/sdk-core/AGENTS.md +73 -0
- package/sdk-core/ARCHITECTURE.md +71 -23
- package/sdk-core/Cargo.toml +1 -1
- package/sdk-core/README.md +4 -4
- package/sdk-core/arch_docs/workflow_task_chunking.md +51 -0
- package/sdk-core/client/Cargo.toml +1 -1
- package/sdk-core/client/src/lib.rs +49 -13
- package/sdk-core/client/src/metrics.rs +15 -16
- package/sdk-core/client/src/proxy.rs +2 -2
- package/sdk-core/client/src/raw.rs +54 -8
- package/sdk-core/client/src/retry.rs +109 -13
- package/sdk-core/client/src/worker_registry/mod.rs +4 -4
- package/sdk-core/client/src/workflow_handle/mod.rs +1 -1
- package/sdk-core/core/Cargo.toml +28 -8
- package/sdk-core/core/src/abstractions.rs +62 -10
- package/sdk-core/core/src/core_tests/activity_tasks.rs +180 -8
- package/sdk-core/core/src/core_tests/mod.rs +4 -4
- package/sdk-core/core/src/core_tests/queries.rs +18 -4
- package/sdk-core/core/src/core_tests/workers.rs +3 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +191 -25
- package/sdk-core/core/src/ephemeral_server/mod.rs +10 -3
- package/sdk-core/core/src/internal_flags.rs +14 -14
- package/sdk-core/core/src/lib.rs +5 -2
- package/sdk-core/core/src/pollers/mod.rs +1 -1
- package/sdk-core/core/src/pollers/poll_buffer.rs +495 -164
- package/sdk-core/core/src/protosext/mod.rs +3 -3
- package/sdk-core/core/src/replay/mod.rs +3 -3
- package/sdk-core/core/src/telemetry/metrics.rs +13 -4
- package/sdk-core/core/src/telemetry/mod.rs +72 -70
- package/sdk-core/core/src/telemetry/otel.rs +51 -54
- package/sdk-core/core/src/test_help/mod.rs +9 -3
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +31 -11
- package/sdk-core/core/src/worker/activities/local_activities.rs +35 -28
- package/sdk-core/core/src/worker/activities.rs +58 -30
- package/sdk-core/core/src/worker/client/mocks.rs +3 -3
- package/sdk-core/core/src/worker/client.rs +155 -53
- package/sdk-core/core/src/worker/mod.rs +103 -95
- package/sdk-core/core/src/worker/nexus.rs +100 -73
- package/sdk-core/core/src/worker/tuner/resource_based.rs +14 -6
- package/sdk-core/core/src/worker/tuner.rs +4 -13
- package/sdk-core/core/src/worker/workflow/history_update.rs +47 -51
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -4
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +127 -32
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +1 -2
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +1 -1
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +55 -42
- package/sdk-core/core/src/worker/workflow/managed_run.rs +45 -35
- package/sdk-core/core/src/worker/workflow/mod.rs +200 -97
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +175 -4
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +38 -36
- package/sdk-core/core-api/Cargo.toml +8 -0
- package/sdk-core/core-api/src/envconfig.rs +1544 -0
- package/sdk-core/core-api/src/lib.rs +2 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +8 -0
- package/sdk-core/core-api/src/telemetry.rs +36 -3
- package/sdk-core/core-api/src/worker.rs +301 -75
- package/sdk-core/docker/docker-compose-telem.yaml +1 -0
- package/sdk-core/etc/prometheus.yaml +6 -2
- package/sdk-core/histories/long_local_activity_with_update-0_history.bin +0 -0
- package/sdk-core/histories/long_local_activity_with_update-1_history.bin +0 -0
- package/sdk-core/histories/long_local_activity_with_update-2_history.bin +0 -0
- package/sdk-core/histories/long_local_activity_with_update-3_history.bin +0 -0
- package/sdk-core/sdk/src/activity_context.rs +5 -0
- package/sdk-core/sdk/src/interceptors.rs +73 -3
- package/sdk-core/sdk/src/lib.rs +15 -16
- package/sdk-core/sdk/src/workflow_context/options.rs +10 -0
- package/sdk-core/sdk/src/workflow_context.rs +48 -29
- package/sdk-core/sdk/src/workflow_future.rs +5 -6
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +20 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/CODEOWNERS +6 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/README.md +17 -6
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/buf.lock +7 -2
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/buf.yaml +2 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +78 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +29 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +74 -32
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +45 -15
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +7 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +3 -3
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +3 -3
- package/sdk-core/sdk-core-protos/protos/api_upstream/LICENSE +1 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +1103 -88
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +1233 -151
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +19 -24
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +12 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +45 -45
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +15 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +4 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -20
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +4 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/export/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +75 -49
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -20
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/query/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/rules/v1/message.proto +90 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +17 -38
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/update/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/version/v1/message.proto +0 -22
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +151 -44
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +172 -65
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +69 -28
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_task/activity_task.proto +18 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/common/common.proto +5 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/nexus/nexus.proto +16 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +21 -15
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +3 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +3 -0
- package/sdk-core/sdk-core-protos/src/lib.rs +60 -16
- package/sdk-core/test-utils/src/lib.rs +157 -39
- package/sdk-core/tests/cloud_tests.rs +86 -0
- package/sdk-core/tests/fuzzy_workflow.rs +23 -26
- package/sdk-core/tests/global_metric_tests.rs +116 -0
- package/sdk-core/tests/heavy_tests.rs +127 -7
- package/sdk-core/tests/integ_tests/client_tests.rs +2 -8
- package/sdk-core/tests/integ_tests/metrics_tests.rs +100 -106
- package/sdk-core/tests/integ_tests/polling_tests.rs +94 -8
- package/sdk-core/tests/integ_tests/update_tests.rs +75 -6
- package/sdk-core/tests/integ_tests/worker_tests.rs +54 -5
- package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +240 -0
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +41 -3
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +168 -8
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +285 -15
- package/sdk-core/tests/integ_tests/workflow_tests/priority.rs +12 -4
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +3 -2
- package/sdk-core/tests/integ_tests/workflow_tests.rs +124 -74
- package/sdk-core/tests/main.rs +3 -51
- package/sdk-core/tests/manual_tests.rs +430 -0
- package/sdk-core/tests/runner.rs +28 -2
- package/src/client.rs +565 -0
- package/src/helpers/abort_controller.rs +204 -0
- package/src/helpers/callbacks.rs +299 -0
- package/src/helpers/errors.rs +302 -0
- package/src/helpers/future.rs +44 -0
- package/src/helpers/handles.rs +191 -0
- package/src/helpers/inspect.rs +18 -0
- package/src/helpers/json_string.rs +58 -0
- package/src/helpers/mod.rs +20 -0
- package/src/helpers/properties.rs +71 -0
- package/src/helpers/try_from_js.rs +213 -0
- package/src/helpers/try_into_js.rs +129 -0
- package/src/lib.rs +28 -40
- package/src/logs.rs +111 -0
- package/src/metrics.rs +325 -0
- package/src/runtime.rs +409 -498
- package/src/testing.rs +315 -57
- package/src/worker.rs +907 -378
- package/ts/errors.ts +57 -0
- package/ts/index.ts +10 -596
- package/ts/native.ts +496 -0
- package/lib/worker-tuner.d.ts +0 -167
- package/lib/worker-tuner.js.map +0 -1
- package/src/conversions/slot_supplier_bridge.rs +0 -291
- package/src/conversions.rs +0 -618
- package/src/errors.rs +0 -38
- package/src/helpers.rs +0 -297
- package/ts/worker-tuner.ts +0 -193
|
@@ -51,7 +51,7 @@ use std::{
|
|
|
51
51
|
sync::Arc,
|
|
52
52
|
time::{Duration, Instant, SystemTime},
|
|
53
53
|
};
|
|
54
|
-
use temporal_sdk_core_api::worker::WorkerConfig;
|
|
54
|
+
use temporal_sdk_core_api::worker::{WorkerConfig, WorkerDeploymentVersion};
|
|
55
55
|
use temporal_sdk_core_protos::{
|
|
56
56
|
coresdk::{
|
|
57
57
|
common::{NamespacedWorkflowExecution, VersioningIntent},
|
|
@@ -123,8 +123,9 @@ pub(crate) struct WorkflowMachines {
|
|
|
123
123
|
history_size_bytes: u64,
|
|
124
124
|
/// Set on each WFT started event
|
|
125
125
|
continue_as_new_suggested: bool,
|
|
126
|
-
/// Set if the current WFT is already complete and that completion event had
|
|
127
|
-
|
|
126
|
+
/// Set if the current WFT is already complete and that completion event had legacy build-id
|
|
127
|
+
/// or a deployment version in it. Will use an empty deployment name if it's legacy build-id.
|
|
128
|
+
current_wft_deployment_info: Option<WorkerDeploymentVersion>,
|
|
128
129
|
|
|
129
130
|
all_machines: SlotMap<MachineKey, Machines>,
|
|
130
131
|
/// If a machine key is in this map, that machine was created internally by core, not as a
|
|
@@ -286,7 +287,7 @@ impl WorkflowMachines {
|
|
|
286
287
|
observed_internal_flags: Rc::new(RefCell::new(observed_internal_flags)),
|
|
287
288
|
history_size_bytes: 0,
|
|
288
289
|
continue_as_new_suggested: false,
|
|
289
|
-
|
|
290
|
+
current_wft_deployment_info: None,
|
|
290
291
|
all_machines: Default::default(),
|
|
291
292
|
machine_is_core_created: Default::default(),
|
|
292
293
|
machines_by_event_id: Default::default(),
|
|
@@ -442,11 +443,11 @@ impl WorkflowMachines {
|
|
|
442
443
|
)
|
|
443
444
|
});
|
|
444
445
|
let is_replaying = self.replaying || all_query;
|
|
445
|
-
let
|
|
446
|
-
self.
|
|
446
|
+
let deployment_version_for_current_task = if is_replaying {
|
|
447
|
+
self.current_wft_deployment_info.clone()
|
|
447
448
|
} else {
|
|
448
|
-
self.
|
|
449
|
-
self.
|
|
449
|
+
self.current_wft_deployment_info = self.worker_config.computed_deployment_version();
|
|
450
|
+
self.current_wft_deployment_info.clone()
|
|
450
451
|
};
|
|
451
452
|
WorkflowActivation {
|
|
452
453
|
timestamp: self.current_wf_time.map(Into::into),
|
|
@@ -460,7 +461,8 @@ impl WorkflowMachines {
|
|
|
460
461
|
.collect(),
|
|
461
462
|
history_size_bytes: self.history_size_bytes,
|
|
462
463
|
continue_as_new_suggested: self.continue_as_new_suggested,
|
|
463
|
-
|
|
464
|
+
deployment_version_for_current_task: deployment_version_for_current_task
|
|
465
|
+
.map(Into::into),
|
|
464
466
|
}
|
|
465
467
|
}
|
|
466
468
|
|
|
@@ -479,9 +481,7 @@ impl WorkflowMachines {
|
|
|
479
481
|
// If this worker has a build ID and we're completing the task, we want to say our ID is the
|
|
480
482
|
// current build ID, so that if we get a query before any new history, we properly can
|
|
481
483
|
// report that our ID was the one used for the completion.
|
|
482
|
-
|
|
483
|
-
self.current_wft_build_id = Some(self.worker_config.worker_build_id.clone());
|
|
484
|
-
}
|
|
484
|
+
self.current_wft_deployment_info = self.worker_config.computed_deployment_version();
|
|
485
485
|
(*self.observed_internal_flags)
|
|
486
486
|
.borrow_mut()
|
|
487
487
|
.gather_for_wft_complete()
|
|
@@ -512,15 +512,11 @@ impl WorkflowMachines {
|
|
|
512
512
|
self.last_processed_event -= 2;
|
|
513
513
|
// Then, we have to drop any state machines (which should only be one workflow task machine)
|
|
514
514
|
// we may have created when servicing the speculative task.
|
|
515
|
-
// Remove when https://github.com/rust-lang/rust/issues/59618 is stable
|
|
516
515
|
let remove_these: Vec<_> = self
|
|
517
516
|
.machines_by_event_id
|
|
518
|
-
.
|
|
519
|
-
.filter(|(mid, _)| **mid > self.last_processed_event)
|
|
520
|
-
.map(|(mid, mkey)| (*mid, *mkey))
|
|
517
|
+
.extract_if(|mid, _| *mid > self.last_processed_event)
|
|
521
518
|
.collect();
|
|
522
|
-
for (
|
|
523
|
-
self.machines_by_event_id.remove(&mid);
|
|
519
|
+
for (_, mkey) in remove_these {
|
|
524
520
|
self.all_machines.remove(mkey);
|
|
525
521
|
}
|
|
526
522
|
}
|
|
@@ -531,10 +527,10 @@ impl WorkflowMachines {
|
|
|
531
527
|
let results = self.drive_me.fetch_workflow_iteration_output();
|
|
532
528
|
self.handle_driven_results(results)?;
|
|
533
529
|
self.prepare_commands()?;
|
|
534
|
-
if self.workflow_is_finished()
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
530
|
+
if self.workflow_is_finished()
|
|
531
|
+
&& let Some(rt) = self.total_runtime()
|
|
532
|
+
{
|
|
533
|
+
self.metrics.wf_e2e_latency(rt);
|
|
538
534
|
}
|
|
539
535
|
Ok(())
|
|
540
536
|
}
|
|
@@ -587,8 +583,28 @@ impl WorkflowMachines {
|
|
|
587
583
|
(*$me.observed_internal_flags)
|
|
588
584
|
.borrow_mut()
|
|
589
585
|
.add_from_complete($wtc);
|
|
586
|
+
let mut combined_ver = WorkerDeploymentVersion {
|
|
587
|
+
deployment_name: "".to_string(),
|
|
588
|
+
build_id: "".to_string(),
|
|
589
|
+
};
|
|
590
|
+
#[allow(deprecated)]
|
|
590
591
|
if let Some(bid) = $wtc.worker_version.as_ref().map(|wv| &wv.build_id) {
|
|
591
|
-
|
|
592
|
+
combined_ver.build_id = bid.to_string();
|
|
593
|
+
}
|
|
594
|
+
if !$wtc.worker_deployment_name.is_empty() {
|
|
595
|
+
combined_ver.deployment_name = $wtc.worker_deployment_name.clone();
|
|
596
|
+
}
|
|
597
|
+
#[allow(deprecated)]
|
|
598
|
+
if !$wtc.worker_deployment_version.is_empty() {
|
|
599
|
+
if let Ok(ver) = $wtc.worker_deployment_version.parse() {
|
|
600
|
+
combined_ver = ver;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
if let Some(dv) = $wtc.deployment_version.as_ref() {
|
|
604
|
+
combined_ver = dv.clone().into();
|
|
605
|
+
}
|
|
606
|
+
if !combined_ver.is_empty() {
|
|
607
|
+
$me.current_wft_deployment_info = Some(combined_ver);
|
|
592
608
|
}
|
|
593
609
|
}};
|
|
594
610
|
}
|
|
@@ -599,13 +615,12 @@ impl WorkflowMachines {
|
|
|
599
615
|
{
|
|
600
616
|
apply_wft_complete_data!(self, wtc);
|
|
601
617
|
}
|
|
602
|
-
if peeked_events.peek().is_none()
|
|
603
|
-
|
|
618
|
+
if peeked_events.peek().is_none()
|
|
619
|
+
&& let Some(wtc) = self
|
|
604
620
|
.last_history_from_server
|
|
605
621
|
.peek_next_wft_completed(event.event_id)
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
622
|
+
{
|
|
623
|
+
apply_wft_complete_data!(self, wtc);
|
|
609
624
|
}
|
|
610
625
|
}
|
|
611
626
|
|
|
@@ -615,10 +630,10 @@ impl WorkflowMachines {
|
|
|
615
630
|
}
|
|
616
631
|
let replay_start = Instant::now();
|
|
617
632
|
|
|
618
|
-
if let Some(last_event) = events.last()
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
633
|
+
if let Some(last_event) = events.last()
|
|
634
|
+
&& last_event.event_type == EventType::WorkflowTaskStarted as i32
|
|
635
|
+
{
|
|
636
|
+
self.next_started_event_id = last_event.event_id;
|
|
622
637
|
}
|
|
623
638
|
|
|
624
639
|
let mut update_admitted_event_messages = HashMap::<String, IncomingProtocolMessage>::new();
|
|
@@ -719,7 +734,7 @@ impl WorkflowMachines {
|
|
|
719
734
|
|
|
720
735
|
// Needed to delay mutation of self until after we've iterated over peeked events.
|
|
721
736
|
enum DelayedAction {
|
|
722
|
-
WakeLa(MachineKey, CompleteLocalActivityData),
|
|
737
|
+
WakeLa(MachineKey, Box<CompleteLocalActivityData>),
|
|
723
738
|
ProtocolMessage(IncomingProtocolMessage),
|
|
724
739
|
}
|
|
725
740
|
let mut delayed_actions = vec![];
|
|
@@ -755,7 +770,7 @@ impl WorkflowMachines {
|
|
|
755
770
|
if let Ok(mk) =
|
|
756
771
|
self.get_machine_key(CommandID::LocalActivity(la_dat.marker_dat.seq))
|
|
757
772
|
{
|
|
758
|
-
delayed_actions.push(DelayedAction::WakeLa(mk, la_dat));
|
|
773
|
+
delayed_actions.push(DelayedAction::WakeLa(mk, Box::new(la_dat)));
|
|
759
774
|
} else {
|
|
760
775
|
self.local_activity_data.insert_peeked_marker(la_dat);
|
|
761
776
|
}
|
|
@@ -787,10 +802,10 @@ impl WorkflowMachines {
|
|
|
787
802
|
let mach = self.machine_mut(mk);
|
|
788
803
|
if let Machines::LocalActivityMachine(ref mut lam) = *mach {
|
|
789
804
|
if lam.will_accept_resolve_marker() {
|
|
790
|
-
let resps = lam.try_resolve_with_dat(la_dat.into())?;
|
|
805
|
+
let resps = lam.try_resolve_with_dat((*la_dat).into())?;
|
|
791
806
|
self.process_machine_responses(mk, resps)?;
|
|
792
807
|
} else {
|
|
793
|
-
self.local_activity_data.insert_peeked_marker(la_dat);
|
|
808
|
+
self.local_activity_data.insert_peeked_marker(*la_dat);
|
|
794
809
|
}
|
|
795
810
|
}
|
|
796
811
|
}
|
|
@@ -1704,13 +1719,11 @@ fn patch_marker_handling(
|
|
|
1704
1719
|
fn skip_one_or_two_events(next_event: Option<&HistoryEvent>) -> Result<EventHandlingOutcome> {
|
|
1705
1720
|
// Also ignore the subsequent upsert event if present
|
|
1706
1721
|
let mut skip_next_event = false;
|
|
1707
|
-
if let Some(history_event::Attributes::UpsertWorkflowSearchAttributesEventAttributes(
|
|
1708
|
-
|
|
1709
|
-
|
|
1722
|
+
if let Some(history_event::Attributes::UpsertWorkflowSearchAttributesEventAttributes(atts)) =
|
|
1723
|
+
next_event.and_then(|ne| ne.attributes.as_ref())
|
|
1724
|
+
&& let Some(ref sa) = atts.search_attributes
|
|
1710
1725
|
{
|
|
1711
|
-
|
|
1712
|
-
skip_next_event = sa.indexed_fields.contains_key(VERSION_SEARCH_ATTR_KEY);
|
|
1713
|
-
}
|
|
1726
|
+
skip_next_event = sa.indexed_fields.contains_key(VERSION_SEARCH_ATTR_KEY);
|
|
1714
1727
|
}
|
|
1715
1728
|
|
|
1716
1729
|
Ok(EventHandlingOutcome::SkipEvent { skip_next_event })
|
|
@@ -23,7 +23,7 @@ use futures_util::future::AbortHandle;
|
|
|
23
23
|
use std::{
|
|
24
24
|
collections::HashSet,
|
|
25
25
|
mem,
|
|
26
|
-
ops::Add,
|
|
26
|
+
ops::{Add, Sub},
|
|
27
27
|
rc::Rc,
|
|
28
28
|
sync::{Arc, mpsc::Sender},
|
|
29
29
|
time::{Duration, Instant},
|
|
@@ -40,7 +40,8 @@ use temporal_sdk_core_protos::{
|
|
|
40
40
|
workflow_completion,
|
|
41
41
|
},
|
|
42
42
|
temporal::api::{
|
|
43
|
-
command::v1::command::Attributes as CmdAttribs,
|
|
43
|
+
command::v1::command::Attributes as CmdAttribs,
|
|
44
|
+
enums::v1::{VersioningBehavior, WorkflowTaskFailedCause},
|
|
44
45
|
failure::v1::Failure,
|
|
45
46
|
},
|
|
46
47
|
};
|
|
@@ -295,10 +296,12 @@ impl ManagedRun {
|
|
|
295
296
|
// Only record latency metrics if we genuinely reported to server
|
|
296
297
|
if let WFTReportStatus::Reported {
|
|
297
298
|
reset_last_started_to,
|
|
299
|
+
completion_time,
|
|
298
300
|
} = report_status
|
|
299
301
|
{
|
|
300
302
|
if let Some(ot) = &retme {
|
|
301
|
-
self.metrics
|
|
303
|
+
self.metrics
|
|
304
|
+
.wf_task_latency(completion_time.sub(ot.start_time));
|
|
302
305
|
}
|
|
303
306
|
if let Some(id) = reset_last_started_to {
|
|
304
307
|
self.wfm.machines.reset_last_started_id(id);
|
|
@@ -372,6 +375,7 @@ impl ManagedRun {
|
|
|
372
375
|
&mut self,
|
|
373
376
|
mut commands: Vec<WFCommand>,
|
|
374
377
|
used_flags: Vec<u32>,
|
|
378
|
+
versioning_behavior: VersioningBehavior,
|
|
375
379
|
resp_chan: Option<oneshot::Sender<ActivationCompleteResult>>,
|
|
376
380
|
is_forced_failure: bool,
|
|
377
381
|
) -> Result<RunUpdateAct, Box<NextPageReq>> {
|
|
@@ -448,6 +452,7 @@ impl ManagedRun {
|
|
|
448
452
|
used_flags,
|
|
449
453
|
resp_chan,
|
|
450
454
|
is_forced_failure,
|
|
455
|
+
versioning_behavior,
|
|
451
456
|
};
|
|
452
457
|
|
|
453
458
|
// Verify we can actually apply the next workflow task, which will happen as part of
|
|
@@ -618,6 +623,7 @@ impl ManagedRun {
|
|
|
618
623
|
metadata: None,
|
|
619
624
|
}],
|
|
620
625
|
vec![],
|
|
626
|
+
VersioningBehavior::Unspecified, // Doesn't matter since we're failing wf
|
|
621
627
|
resp_chan,
|
|
622
628
|
true,
|
|
623
629
|
)
|
|
@@ -690,6 +696,7 @@ impl ManagedRun {
|
|
|
690
696
|
has_pending_query: completion.has_pending_query,
|
|
691
697
|
activation_was_eviction: completion.activation_was_eviction,
|
|
692
698
|
is_forced_failure: completion.is_forced_failure,
|
|
699
|
+
versioning_behavior: completion.versioning_behavior,
|
|
693
700
|
};
|
|
694
701
|
|
|
695
702
|
self.wfm.machines.add_lang_used_flags(completion.used_flags);
|
|
@@ -772,17 +779,17 @@ impl ManagedRun {
|
|
|
772
779
|
) -> Result<Option<FulfillableActivationComplete>, RunUpdateErr> {
|
|
773
780
|
debug!(resolution=?res, "Applying local resolution");
|
|
774
781
|
self.wfm.notify_of_local_result(res)?;
|
|
775
|
-
if self.wfm.machines.outstanding_local_activity_count() == 0
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
782
|
+
if self.wfm.machines.outstanding_local_activity_count() == 0
|
|
783
|
+
&& let Some(mut wait_dat) = self.waiting_on_la.take()
|
|
784
|
+
{
|
|
785
|
+
// Cancel the heartbeat timeout
|
|
786
|
+
wait_dat.hb_timeout_handle.abort();
|
|
787
|
+
if let Some((completion_dat, resp_chan)) = wait_dat.completion_dat.take() {
|
|
788
|
+
return Ok(Some(self.prepare_complete_resp(
|
|
789
|
+
resp_chan,
|
|
790
|
+
completion_dat,
|
|
791
|
+
false,
|
|
792
|
+
)));
|
|
786
793
|
}
|
|
787
794
|
}
|
|
788
795
|
Ok(None)
|
|
@@ -896,10 +903,9 @@ impl ManagedRun {
|
|
|
896
903
|
// If the wft was just a legacy query, still reply, otherwise we might try to
|
|
897
904
|
// reply to the task as if it were a task rather than a query.
|
|
898
905
|
&& !self.pending_work_is_legacy_query()
|
|
906
|
+
&& let Some(wft) = self.wft.as_mut()
|
|
899
907
|
{
|
|
900
|
-
|
|
901
|
-
wft.pending_queries.clear();
|
|
902
|
-
}
|
|
908
|
+
wft.pending_queries.clear();
|
|
903
909
|
}
|
|
904
910
|
|
|
905
911
|
self.trying_to_evict = Some(info);
|
|
@@ -1007,7 +1013,8 @@ impl ManagedRun {
|
|
|
1007
1013
|
}
|
|
1008
1014
|
Err(fail) => {
|
|
1009
1015
|
self.am_broken = true;
|
|
1010
|
-
|
|
1016
|
+
|
|
1017
|
+
if let Some(resp_chan) = fail.complete_resp_chan {
|
|
1011
1018
|
// Automatically fail the workflow task in the event we couldn't update machines
|
|
1012
1019
|
let fail_cause = if matches!(&fail.source, WFMachinesError::Nondeterminism(_)) {
|
|
1013
1020
|
WorkflowTaskFailedCause::NonDeterministicError
|
|
@@ -1027,8 +1034,7 @@ impl ManagedRun {
|
|
|
1027
1034
|
run_id: self.run_id().to_owned(),
|
|
1028
1035
|
machines_err: fail.source,
|
|
1029
1036
|
})
|
|
1030
|
-
}
|
|
1031
|
-
rur
|
|
1037
|
+
}
|
|
1032
1038
|
}
|
|
1033
1039
|
}
|
|
1034
1040
|
}
|
|
@@ -1118,8 +1124,10 @@ impl ManagedRun {
|
|
|
1118
1124
|
Some(CmdAttribs::CompleteWorkflowExecutionCommandAttributes(_)) => {
|
|
1119
1125
|
self.metrics.wf_completed();
|
|
1120
1126
|
}
|
|
1121
|
-
Some(CmdAttribs::FailWorkflowExecutionCommandAttributes(
|
|
1122
|
-
|
|
1127
|
+
Some(CmdAttribs::FailWorkflowExecutionCommandAttributes(attrs)) => {
|
|
1128
|
+
if metrics::should_record_failure_metric(&attrs.failure) {
|
|
1129
|
+
self.metrics.wf_failed();
|
|
1130
|
+
}
|
|
1123
1131
|
}
|
|
1124
1132
|
Some(CmdAttribs::ContinueAsNewWorkflowExecutionCommandAttributes(_)) => {
|
|
1125
1133
|
self.metrics.wf_continued_as_new();
|
|
@@ -1139,6 +1147,7 @@ impl ManagedRun {
|
|
|
1139
1147
|
messages,
|
|
1140
1148
|
query_responses,
|
|
1141
1149
|
sdk_metadata: machines_wft_response.metadata_for_complete(),
|
|
1150
|
+
versioning_behavior: data.versioning_behavior,
|
|
1142
1151
|
},
|
|
1143
1152
|
})
|
|
1144
1153
|
} else {
|
|
@@ -1172,25 +1181,24 @@ impl ManagedRun {
|
|
|
1172
1181
|
outcome: ActivationCompleteOutcome,
|
|
1173
1182
|
chan: Option<oneshot::Sender<ActivationCompleteResult>>,
|
|
1174
1183
|
) {
|
|
1175
|
-
if let Some(chan) = chan
|
|
1176
|
-
|
|
1184
|
+
if let Some(chan) = chan
|
|
1185
|
+
&& chan
|
|
1177
1186
|
.send(ActivationCompleteResult {
|
|
1178
1187
|
outcome,
|
|
1179
1188
|
replaying: self.wfm.machines.replaying,
|
|
1180
1189
|
})
|
|
1181
1190
|
.is_err()
|
|
1182
|
-
|
|
1183
|
-
|
|
1191
|
+
{
|
|
1192
|
+
let warnstr = "The workflow task completer went missing! This likely indicates an \
|
|
1184
1193
|
SDK bug, please report."
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
}
|
|
1194
|
+
.to_string();
|
|
1195
|
+
warn!(run_id=%self.run_id(), "{}", warnstr);
|
|
1196
|
+
self.request_eviction(RequestEvictMsg {
|
|
1197
|
+
run_id: self.run_id().to_string(),
|
|
1198
|
+
message: warnstr,
|
|
1199
|
+
reason: EvictionReason::Fatal,
|
|
1200
|
+
auto_reply_fail_tt: None,
|
|
1201
|
+
});
|
|
1194
1202
|
}
|
|
1195
1203
|
}
|
|
1196
1204
|
|
|
@@ -1337,6 +1345,7 @@ struct CompletionDataForWFT {
|
|
|
1337
1345
|
has_pending_query: bool,
|
|
1338
1346
|
activation_was_eviction: bool,
|
|
1339
1347
|
is_forced_failure: bool,
|
|
1348
|
+
versioning_behavior: VersioningBehavior,
|
|
1340
1349
|
}
|
|
1341
1350
|
|
|
1342
1351
|
/// Manages an instance of a [WorkflowMachines], which is not thread-safe, as well as other data
|
|
@@ -1481,6 +1490,7 @@ struct RunActivationCompletion {
|
|
|
1481
1490
|
/// Used to notify the worker when the completion is done processing and the completion can
|
|
1482
1491
|
/// unblock. Must always be `Some` when initialized.
|
|
1483
1492
|
resp_chan: Option<oneshot::Sender<ActivationCompleteResult>>,
|
|
1493
|
+
versioning_behavior: VersioningBehavior,
|
|
1484
1494
|
}
|
|
1485
1495
|
#[derive(Debug, derive_more::From)]
|
|
1486
1496
|
enum ActOrFulfill {
|