Skip to content

re_grpc: end a finished action's Execute stream with the server, not with a reset - #1651

Open
jun-mercury wants to merge 1 commit into
meta:mainfrom
mercury:upstream/re-grpc-execute-stream-end
Open

jun-mercury wants to merge 1 commit into
meta:mainfrom
mercury:upstream/re-grpc-execute-stream-end

Conversation

@jun-mercury

Copy link
Copy Markdown
Contributor

Summary

The executor drops an action's Execute stream once its done Operation arrives, and h2 resets the dropped stream with CANCEL while the server's trailers are still in flight. h2 remembers only a bounded set of recently reset streams. A frame for a stream it has forgotten is answered with a reset that h2 counts against the connection, and that count never goes down (h2 0.4, src/proto/streams). Over a long-lived daemon, about the 1,025th such reset becomes GOAWAY ENHANCE_YOUR_CALM "too_many_internal_resets", the error the comment on retrying_stream in execute_with_progress names, and every stream on the connection fails with it.

The stream that execute_with_progress opens now ends at the done Operation, so retrying_stream stops there, and a reset that comes after it isn't retried. When the stream is dropped, a task reads what's left of it up to the server's END_STREAM, for at most 2 s. BuildBuddy writes the trailers right after the done Operation, and a stream held open longer keeps one of the server's concurrent streams. A stream dropped before its done Operation is still reset, which is what tells the server to stop.

Test plan

  • New tests in remote_execution/oss/re_grpc/src/client.rs: the stream ends at its done Operation, and its remainder is drained.
  • cargo test -p remote_execution --lib: 56 passed.

…with a reset

The executor drops an action's Execute stream once its done Operation is
in, and h2 resets a dropped stream with CANCEL while the server's trailers
are still on the way. h2 keeps only a bounded set of recently reset
streams. A frame that arrives for one it has forgotten is answered with a
reset that h2 counts against the connection, and that count never goes
down (h2 0.4 src/proto/streams). Over a long-lived daemon the 1025th
becomes GOAWAY ENHANCE_YOUR_CALM "too_many_internal_resets", the error the
comment on retrying_stream in execute_with_progress names, and every
stream on the connection fails with it.

The stream that execute_with_progress opens now ends at the done
Operation, so retrying_stream never reads past it and so never retries
a reset that comes after it. When the stream is dropped, a task reads
what is left of it to the server's END_STREAM, for at most 2 s.
BuildBuddy writes the trailers right after the done Operation, and a
stream held open longer keeps one of the server's concurrent streams. A
stream dropped before its done Operation is still reset, which is what
tells the server to stop.

Assisted-by: Claude:claude-opus-5-5
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 25, 2026
@meta-codesync

meta-codesync Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D134506953. (Because this pull request was imported automatically, there will not be any future comments.)

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant