Wire request_id through CallbackInfo for linking - #851
Conversation
| // Source execution the callback was attached to. | ||
| Execution execution = 1; | ||
| // Request ID used for the callback's delivery. | ||
| string request_id = 2; |
There was a problem hiding this comment.
I think we should consider creating a "callback ID" as fully supported thing. The ambiguity where the request ID can be shared across multiple callbacks feels a little awkward.
There was a problem hiding this comment.
Strong +1 to this. We just need a way to uniquely identify a worker callback within the scope of an execution, and having an entirely server-side generated ID removes any potential confusion.
Moreover, having it be an entirely Temporal-managed CallbackInfo::callback_id and not a user-editable Callback::id simplifies things even more.
There was a problem hiding this comment.
There's no user-editable callback::id. I'd be more than okay using the request ID as the callback ID since it is a unique identifier as long as we document it.
79aa66f to
e5678ad
Compare
| // If the state is BLOCKED, blocked reason provides additional information. | ||
| string blocked_reason = 8; | ||
|
|
||
| // The Request ID used when the Callback was delivered. Used as an idempotency key in case multiple deliveries |
There was a problem hiding this comment.
I would decouple the user provided request ID from the one the system generates. The start request is not the same as the callback delivery request and those should have different IDs. I would be confused if I saw the same request ID provided in a log for different purposes.
There was a problem hiding this comment.
I am concerned that this will be confused with the request ID of the start request used to attach this callback. Document the semantics as we did here:
api/temporal/api/nexus/v1/message.proto
Lines 308 to 311 in 7868510
There was a problem hiding this comment.
Thanks for linking to the comment, I agree that's exactly how we'd want to define it.
| // Source execution the callback was attached to. | ||
| Execution execution = 1; | ||
| // Request ID used for the callback's delivery. | ||
| string request_id = 2; |
There was a problem hiding this comment.
There's no user-editable callback::id. I'd be more than okay using the request ID as the callback ID since it is a unique identifier as long as we document it.
| // A Nexus operation execution archetype. This is reserved for standalone Nexus operations. | ||
| EXECUTION_TYPE_NEXUS = 3; | ||
| // An update workflow execution archtype. | ||
| EXECUTION_TYPE_UPDATE_WORKFLOW = 4; |
There was a problem hiding this comment.
This is not an "execution", it's a component within an execution.
| EXECUTION_TYPE_ACTIVITY = 2; | ||
| } No newline at end of file | ||
| // A Nexus operation execution archetype. This is reserved for standalone Nexus operations. | ||
| EXECUTION_TYPE_NEXUS = 3; |
There was a problem hiding this comment.
| EXECUTION_TYPE_NEXUS = 3; | |
| EXECUTION_TYPE_NEXUS_OPERATION = 3; |
08c0da4 to
18f2186
Compare
|
Addressed PR feedback. However, after the blueprint review we will scope worker callbacks to just SANO operations. So I removed the new fields added to |
18f2186 to
54d5276
Compare
feature/worker-callbacksbranch, and notmain. Only after the feature is complete will that branch be rebased and merged intomain.This PR makes three changes, all so that resources spanwed from the invocation of a worker callback can be linked correctly.
(1) Remove the
Link_NexusOperationCallbackvariant with a more generalLink_CallbackprotoPreviously we were scoping the feature to only be applicable for SANO callbacks. But if we are going to support worker callbacks for any async operation, having a general link type (that uses the existing Execution proto) will avoid needing to create additional link variants in the future.
(2) Add a
callbackpb.CallbackInfo::request_idfieldThis type is used in the
Describe-operations for standalone Activities and standalone Nexus operations. Without it, there would be no way to determine which completion callback is being referred to. (Instead, we couldn't be any more accurate than to have the link point to "one of these N" callbacks.)(3) Add
workflowpb.CallbackInfo::{request_id, result}The
workflowpbnamespace forked rather than embedded thecallbackpb.CallbackInfomessage. The changes here add the missing fields, so thatDescribeWorkflowExecutioncan disambiguate callbacks as well. (In addition to carrying the result of those callbacks.)Why?
With these changes, the server will be able to properly cross-link resources spawned from completion callbacks.
On the Caller-side, any resources spawned from the completion callbacks would be available on the
commonpb.Callback::linksfield. (*)On the Handler-side, a single
Link_Callbackwould be supplied to the Nexus handler receiving the worker callback. (This would be in the form of anexuspb.Link.)Breaking changes
Yes, this PR contains breaking proto changes. However, in the context of a PR into a long-lived feature branch for an unshipped feature this is safe. (The protos haven't ever been persisted by a production service.)
Server PR
It isn't out yet, but will be stacked on top of this:
temporalio/temporal#11589