fix(envoy-client): dedupe replayed commands by index#4811
Draft
NathanFlurry wants to merge 1 commit intoengine-stabilize/envoy-client-lifecyclefrom
Draft
fix(envoy-client): dedupe replayed commands by index#4811NathanFlurry wants to merge 1 commit intoengine-stabilize/envoy-client-lifecyclefrom
NathanFlurry wants to merge 1 commit intoengine-stabilize/envoy-client-lifecyclefrom
Conversation
87d1a9d to
ab8fd17
Compare
This was referenced Apr 27, 2026
Member
Author
This was referenced Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stack Context
Builds on #4801 (
engine-stabilize/envoy-client-lifecycle), which already addedan immediate
send_command_ackafter everyhandle_commandsbatch. This PRcloses the residual race where a command arrives, is processed, but the ack
frame doesn't reach the engine before the WS drops — on reconnect,
pegboard-envoyre-streams the same command from UDB and the envoy processesit twice.
Why?
EnvoyContext::handle_commandshad no dedup on the receive path. Two concretebugs:
CommandStartActorclobbered live actors.insert_actorunconditionally re-
inserts intoctx.actors[actor_id][generation],dropping the existing handle,
event_history, andactive_http_request_counton the floor. The spawned actor task was orphaned.
CommandStopActorre-firedToActor::Stop. Idempotent inbest case, double-shutdown signal in worst case.
ActorEntry::last_command_idxalready existed but was only read bysend_command_ack— never checked against incoming command indices.What?
EnvoyContextgainsprocessed_command_idx: HashMap<(String, u32), i64>.Persists across
remove_actorso a replayed start for analready-stopped actor cannot resurrect it.
handle_commandsskips any command whosecheckpoint.index <= last_processedfor the
(actor_id, generation)pair, then records the new index beforedispatching.
tests/command_dedup.rscovers same-index replay,stale lower-index replay, monotonic processing, and per-actor / per-generation
isolation. Lives in
tests/rather than inline#[cfg(test)] mod testsbecause a pre-existing 7-vs-8 arg mismatch in
actor.rstest code blocks thelib-test target on this branch — the integration test target compiles
independently.
Test plan
cargo check -p rivet-envoy-clientcargo test -p rivet-envoy-client --test command_dedup(2 passed)