-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Problem
The StartMessage in the service protocol (V1-V6) requires all state entries to be embedded in the message itself. This means the server must materialize all state entries into memory before sending the message, and the total state size is bounded by the max message size limit (~32MB).
The server-side implementation in restatedev/restate#4344 / restatedev/restate#4413 introduces protocol V7, which streams state entries in batches after the StartMessage using two new control messages.
Protocol V7 Changes
Two new control message types (server → SDK only):
EagerStateEntryMessage(0x0006): Carries a batch ofStateEntrykey-value pairs. Sent zero or more times.EagerStateCompleteMessage(0x0007): Terminates the eager state stream. Sent exactly once. Containspartial_state: boolindicating whether the combined state is a complete or partial view.
V7 message sequence:
StartMessage (state_map: [], partial_state: ignored)
EagerStateEntryMessage { state_map: [...] } ← 0 or more
EagerStateCompleteMessage { partial_state } ← exactly 1
CommandMessage / NotificationMessage ... ← journal replay
V1-V6 behavior is completely unchanged.
Required Changes in sdk-shared-core
1. Protocol Version
- Add
V7 = 7to theVersionenum insrc/service_protocol/version.rs - Update
maximum_supported_version()to returnV7 - Add content-type string
application/vnd.restate.invocation.v7
2. Protobuf / Generated Code
- Update the
service-protocolsubmodule to include the new proto definitions - Regenerate
src/service_protocol/generated/dev.restate.service.protocol.rs - New message types:
EagerStateEntryMessageandEagerStateCompleteMessage
3. Message Types and Codec
- Add
EagerStateEntry = 0x0006andEagerStateComplete = 0x0007to theMessageTypeenum insrc/service_protocol/header.rs - Add encode/decode support in
src/service_protocol/encoding.rsandmessages.rs
4. VM State Machine
- Add a new intermediate state
WaitingEagerStatebetweenWaitingStartandWaitingReplayEntries - In V7:
StartMessagetransitions toWaitingEagerState(with emptyEagerState) EagerStateEntryMessageaccumulates entries intoEagerStateEagerStateCompleteMessagesetspartial_stateand transitions toWaitingReplayEntries- In V5/V6: behavior unchanged — state comes from
StartMessage.state_map, transitions directly toWaitingReplayEntries
5. Error Handling
- In
WaitingEagerState: reject any message that isn'tEagerStateEntryMessageorEagerStateCompleteMessage - In other states: reject
EagerStateEntryMessage/EagerStateCompleteMessageas protocol errors - In V5/V6: reject the new message types entirely
6. Tests
- V7 with no state entries (immediate
EagerStateCompleteMessage) - V7 with a single batch of entries
- V7 with multiple batches
- V7 with
partial_state: trueandpartial_state: false - Verify V5/V6 behavior is unchanged
- Verify error on receiving new messages in wrong states
Related
- Server-side issue: restatedev/restate#4344
- Server-side PR: restatedev/restate#4413
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels