Skip to content

[service-protocol] Add support for suspension message V7#4601

Open
muhamadazmy wants to merge 2 commits intorestatedev:mainfrom
muhamadazmy:pr4601
Open

[service-protocol] Add support for suspension message V7#4601
muhamadazmy wants to merge 2 commits intorestatedev:mainfrom
muhamadazmy:pr4601

Conversation

@muhamadazmy
Copy link
Copy Markdown
Contributor

@muhamadazmy muhamadazmy commented Apr 16, 2026

[service-protocol] Add support for suspension message V7

Summary:
This adds support to handle which suspension message to decode
based on the protocol version. It also introduce the Suspension message V7
based on the new protocol.proto schema

Update the invocation Suspended state to store and handle
the awaiting on field


Stack created with Sapling. Best reviewed with ReviewStack.

Copy link
Copy Markdown
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

followup here is to enable via env the new protocol version negotiation in types service_protocol.rs, like was done back in this PR 2ce3607#diff-6442aa1f30aedc9c7fc4b6536f57b25d548f18508fc1e27195fe53eb001c8927R48

This way we can test the handling of the message already.

Comment thread crates/worker/src/partition/state_machine/mod.rs Outdated
Comment thread crates/invoker-api/src/effects.rs Outdated
Comment thread crates/invoker-api/src/effects.rs Outdated
Comment thread service-protocol/dev/restate/service/protocol.proto
@muhamadazmy muhamadazmy changed the title [service-protocol] Add support for suspension message V7 [wip] [service-protocol] Add support for suspension message V7 Apr 20, 2026
@muhamadazmy muhamadazmy force-pushed the pr4601 branch 2 times, most recently from 1249780 to acb54e7 Compare April 20, 2026 10:36
@muhamadazmy muhamadazmy changed the title [wip] [service-protocol] Add support for suspension message V7 [service-protocol][wip] Add support for suspension message V7 Apr 20, 2026
@muhamadazmy muhamadazmy changed the title [service-protocol][wip] Add support for suspension message V7 [service-protocol] Add support for suspension message V7 Apr 20, 2026
@muhamadazmy muhamadazmy force-pushed the pr4601 branch 2 times, most recently from 3307bc9 to 477efa7 Compare April 20, 2026 13:53
Comment thread crates/invoker-impl/src/lib.rs Outdated
}
InvocationTaskOutputInner::SuspendedV2(notification_ids) => {
self.handle_invocation_task_suspended_v2(partition, invocation_id, notification_ids).await
InvocationTaskOutputInner::SuspendedV2(combinator) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and everywhere you use the word combinator for future, replace it with future :)

Comment thread crates/invoker-impl/src/lib.rs Outdated
partition: PartitionLeaderEpoch,
invocation_id: InvocationId,
waiting_for_notifications: HashSet<NotificationId>,
combinator: UnresolvedFuture,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

future

// service protocol messages. Otherwise, crates depending only on this feature fail clippy.
#[allow(dead_code)]
mod proto {
pub mod proto {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why pub?

// If set, ignore the awaiting_for_* notifications above (17, 23, and 24)
// the awaiting_for_* are written as a flattened version of awaiting_on
// for Restate <= v1.7
optional dev.restate.service.protocol.Future awaiting_on = 32;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional is not needed here, it's ignored for non-primitive fields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right

Comment thread crates/storage-api/proto/dev/restate/storage/v1/domain.proto
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/worker/src/partition/state_machine/entries/notification.rs Outdated
Comment thread crates/worker/src/partition/state_machine/entries/notification.rs Outdated
@muhamadazmy muhamadazmy force-pushed the pr4601 branch 4 times, most recently from e41bdbf to 418ba05 Compare April 21, 2026 15:42
Copy link
Copy Markdown
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOs as followup to complete this:

  • we need to make sure both sys_invocation_status and sys_invocation_state propagate the new unresolved future info.

Comment thread crates/invoker-api/src/effects.rs Outdated
Suspended {
metadata: InFlightInvocationMetadata,
waiting_for_notifications: HashSet<NotificationId>,
awaiting_on: UnresolvedFuture,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:star-struck:

Comment thread crates/storage-api/src/invocation_status_table/mod.rs
Comment thread crates/types/src/config/common.rs
Comment thread crates/types/src/config/common.rs
Comment thread crates/invoker-impl/src/invocation_task/service_protocol_runner_v4.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/types/src/journal_v2/notification.rs Outdated
Comment thread crates/worker/src/partition/state_machine/lifecycle/suspend.rs Outdated
Comment thread crates/worker/src/partition/state_machine/lifecycle/suspend.rs
@muhamadazmy muhamadazmy force-pushed the pr4601 branch 2 times, most recently from ab5f4ae to 807d98b Compare April 21, 2026 16:31
@muhamadazmy muhamadazmy marked this pull request as ready for review April 21, 2026 17:01
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some minor things. resolve the pending comments, and then we should start to bring some of this stuff in

Comment thread crates/types/src/journal_v2/unresolved_future.rs Outdated
Comment thread crates/types/src/journal_v2/unresolved_future.rs Outdated
Comment thread crates/types/src/journal_v2/unresolved_future.rs Outdated
Comment thread crates/types/src/journal_v2/unresolved_future.rs Outdated
Comment thread crates/types/src/journal_v2/unresolved_future.rs Outdated
Comment thread crates/worker/src/partition/state_machine/lifecycle/suspend.rs Outdated
Comment thread crates/worker/src/partition/state_machine/lifecycle/suspend.rs
Comment thread crates/types/src/journal_v2/unresolved_future.rs
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Copy link
Copy Markdown
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another thing that we're missing is normalization of the future before proposing it in the invoker effects. we can assume the sdk behaves fine, but we must solve this before release to be defensive against sdk bugs.

@muhamadazmy muhamadazmy force-pushed the pr4601 branch 6 times, most recently from 0acf62d to 2e9934f Compare April 22, 2026 08:29
…e/decode

Summary:
This PR allows the messages (MessageType) to know the current service-protocol-version
and then decide how to decode/encode to work the support version for the deployment.

Note: For opaque messages, these are written as is to bifrost, and hence can't be verified against
the select protocol-version.
Summary:
This adds support to handle which suspension message to decode
based on the protocol version. It also introduce the Suspension message V7
based on the new protocol.proto schema

Update the invocation Suspended state to store and handle
the awaiting on field
Comment on lines +49 to +53
impl Default for UnresolvedFuture {
fn default() -> Self {
Self::Unknown(Vec::default())
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo you should remove this too, as this is at all effects an invalid future.

// Should be treated as FirstCompleted,
// Used with Suspension V2 to indicate that
// the sdk did not provide a combinator kind
#[default]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this default too, i think it doesn't make a lot of sense

Comment on lines +25 to +26
// Used with Suspension V2 to indicate that
// the sdk did not provide a combinator kind
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but this is also used by the sdk too sometimes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Unknown has a subtle semantic difference with FirstCompleted:

  • FirstCompleted completes with success if the first completed child future was successful, or completes with failure if the first completed child future failed.
  • For Unknown, if the first completed child future succeeds, we can't tell if Unknown itself will be marked as success or failure. The SDK can flip the result from success to failure, or viceversa.

self
}

pub fn build(self) -> UnresolvedFuture {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we fail if there's no childs here?

}
}

pub struct UnresolvedFutureBuilder {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given you use this only when doing tryfrom/into for storage protobuf conversions, maybe just move it there to keep this file slimmer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in tests you made those factory methods, you can just use those 🤷

Copy link
Copy Markdown
Contributor Author

@muhamadazmy muhamadazmy Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tryfrom/into implementation is in 2 different palce (one for the protocol and the other for the storage) so it's better to have it in a common place

pub enum RawNotificationResultVariant {
/// `Unknown` indicates no result is stored, which is the case
/// for notifications created before Restate v1.7.
#[default]
Copy link
Copy Markdown
Contributor

@slinkydeveloper slinkydeveloper Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of having these defaults, especially for these unknown situations, they're a recipe for misuse :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is useful with serde. I think we should keep it. this way older notification entries with no result is set to unknown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants