Skip to content

Commit b3acbe2

Browse files
authored
Improved retry policy handling (#1012)
* Validating and augmenting retry policy for local activities with default values * Protecting against crashes due to malformed retry policy from server
1 parent 8bd6f59 commit b3acbe2

4 files changed

Lines changed: 292 additions & 132 deletions

File tree

core/src/protosext/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub(crate) mod protocol_messages;
33
use crate::{
44
CompleteActivityError, TaskToken,
55
protosext::protocol_messages::IncomingProtocolMessage,
6+
retry_logic::ValidatedRetryPolicy,
67
worker::{LEGACY_QUERY_ID, LocalActivityExecutionResult},
78
};
89
use anyhow::anyhow;
@@ -32,7 +33,7 @@ use temporal_sdk_core_protos::{
3233
workflow_completion,
3334
},
3435
temporal::api::{
35-
common::v1::{Payload, RetryPolicy, WorkflowExecution},
36+
common::v1::{Payload, WorkflowExecution},
3637
enums::v1::EventType,
3738
failure::v1::Failure,
3839
history::v1::{History, HistoryEvent, MarkerRecordedEventAttributes, history_event},
@@ -318,7 +319,7 @@ pub(crate) struct ValidScheduleLA {
318319
pub(crate) arguments: Vec<Payload>,
319320
pub(crate) schedule_to_start_timeout: Option<Duration>,
320321
pub(crate) close_timeouts: LACloseTimeouts,
321-
pub(crate) retry_policy: RetryPolicy,
322+
pub(crate) retry_policy: ValidatedRetryPolicy,
322323
pub(crate) local_retry_threshold: Duration,
323324
pub(crate) cancellation_type: ActivityCancellationType,
324325
pub(crate) user_metadata: Option<UserMetadata>,
@@ -408,7 +409,8 @@ impl ValidScheduleLA {
408409
));
409410
}
410411
};
411-
let retry_policy = v.retry_policy.unwrap_or_default();
412+
let retry_policy =
413+
ValidatedRetryPolicy::from_proto_with_defaults(v.retry_policy.unwrap_or_default());
412414
let local_retry_threshold = v
413415
.local_retry_threshold
414416
.try_into_or_none()

0 commit comments

Comments
 (0)