Repository navigation
Shrink worker egress: gzip and the server capabilities digest - #304
Merged
Merged
Conversation
Build reqwest with its gzip feature, so every request sends Accept-Encoding: gzip and compressed answers are decoded (server#1261). Worker-plane requests send X-Durable-Workflow-Server-Capabilities-Digest with the digest this Client holds, or none (server#1262). The digest and capabilities object are captured when each request is built, and that request's answer (success or error, top level and up to two objects deep) is restored against the captured pair before any reader sees it. A tagged copy is stripped of its digest member and used for later requests; clones share it. Overlapping requests across a rolling deploy therefore each restore their own capabilities. A digest string that matches neither the request's digest nor a tagged copy in the same answer is Error::Protocol (server_capabilities_digest_unknown). Bodies are re-serialized only when something was restored or stripped. Lab run against native Server main 43ad8d8f, 20 standard one-activity workflows: response bytes per workflow fell from 158.7 KB to 8.8 KB for the worker and from 19.3 KB to 4.7 KB for the caller. No public API change; cargo semver-checks against 4.21.0 reports no semver update required. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rmcdaniel
force-pushed
the
general/egress-digest-gzip
branch
from
November 20, 2026 05:26
4699b4e to
0b65da1
Compare
Review fixes for the digest and gzip change. An answer naming a digest the request did not send used to be Error::Protocol, which ended the worker on the first garbled poll. The Client now forgets its held digest and resends that same request once with "none", which returns full (tagged) capabilities. A resent report the Server already committed comes back as its usual non-recorded receipt (409 stale_attempt for an activity completion, task_not_leased for a workflow task), which the worker already settles. Only an unknown digest on the resend is a protocol failure. Decoded bodies were read with bytes(), so a small gzip answer could expand without bound. Bodies now stream with a cap, 128 MiB by default and configurable with ClientBuilder::max_response_bytes; a larger body fails with the new Error::ResponseBodyTooLarge (Error is non_exhaustive). Raw requests use the same cap. cargo semver-checks against 4.21.0: no semver update required. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With full-jitter renewal backoff (#303) a retry can be drawn near zero and fire before the callback settles, so the test now asserts at least one renewal instead of exactly one. Seen on the Rust 1.86 CI job. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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.



Items 1 and 2 of #302: worker egress. It builds on durable-workflow/server#1261 (gzip) and durable-workflow/server#1262 (capabilities digest), both now merged to server main. The PHP reference is durable-workflow/sdk-php#446. This PR is separate from #303.
Change
gzip. reqwest is now built with its
gzipfeature, so every request sendsAccept-Encoding: gzipand compressed answers are decoded transparently.Cargo.lockadds only the compression crates:async-compression,compression-codecs/-core,flate2,zlib-rs/miniz_oxide,crc32fast,simd-adler32andtokio-util. All of them build on Rust 1.86 (cargo +1.86.0 check --all-targetspasses).Capabilities digest (new
src/server_capabilities_digest.rs, followingdocs/contracts/server-capabilities-digest.md):X-Durable-Workflow-Server-Capabilities-Digest: <digest>|none. Control-plane requests don't send it.send_json_with_timeout, the(digest, capabilities)pair is captured when the request is built, and storage-admission retries reuse it.server_capabilitiesat the top level and up to two objects deep, as in a carried poll'sanswer.digestmember has that member stripped. The pair then becomes the one later requests send. Clones of aClientshare it.none, which returns full, tagged capabilities.409 stale_attemptfor an activity completion,task_not_leasedfor a workflow task. The worker already settles both.Error::Protocolwith reasonserver_capabilities_digest_unknown.ClientBuilder::max_response_bytes. A larger body stops being read and fails with the newError::ResponseBodyTooLarge { limit_bytes }. This is additive becauseErroris#[non_exhaustive]. Raw requests use the same cap. It closes the review finding that a 1.5 MB gzip body expanded to 3.2 GB.server_capabilities_digestpartly because rustfmt sortsmodlines. Under the namecapabilities_digest, the new line landed right aftermod cancellation_scope_replay;, and the regression-corpus guard counted that neighbouring line as replay code. Nothing here touches replay.API. Additive only:
ClientBuilder::max_response_bytesandError::ResponseBodyTooLarge.cargo semver-checks --baseline-version 4.21.0(v0.51.0) reports229 checks: 229 pass, 31 skipandSummary no semver update required.Measurement
general-egress-server:main-43ad8d8f, reports 3.17.0-main43ad8d8f), with sqlite and compression enabled by default. One container, capped at 1 CPU and 768 MB.result()polling every 500 ms. The worker and the caller run in the same process.origin/mainversus this branch.Both runs completed 20 out of 20 workflows with 0 failures in about 40 s. The worker's request bytes grew from 7.6 KB to 8.6 KB per workflow, because of the extra headers.
Tests
server_capabilities_digest::tests(6)tests/server_capabilities_digest.rs:worker_answers_are_restored_from_the_digest_each_request_sentnoneand recovers. An unknown digest on the resend isError::Protocol.tests/server_capabilities_digest.rs:a_completion_resent_after_a_garbled_answer_gets_its_committed_receipt409 stale_attemptreceipt.tests/server_capabilities_digest.rs:decoded_response_bodies_are_cappedError::ResponseBodyTooLarge.tests/server_capabilities_digest.rs(public API)Accept-Encoding: gzipand a gzip answer decodes. Worker polls sendnone, then the learned digest; the tagged copy is stripped, the digest string is restored, and an unknown digest raisesError::Protocol. Control-plane requests don't send the header.Results:
cargo fmt --check: clean.cargo clippy --all-targets --all-features -- -D warnings: clean.cargo test: 1103 passed, 0 failed, 82 ignored (server-gated).cargo +1.86.0 check --all-targets: passes.🤖 Generated with Claude Code