Repository navigation
fix(cache): bound each cache read with a size-scaled deadline - #270
Merged
Merged
Conversation
A stalled remote peer read (GetStream / GetRangeStream, including the [0,0] presence probes) held a request until the client disconnected or the server's 5-minute WriteTimeout fired: cache reads had no deadline of their own. Give every cache read in the proxy its own context.WithTimeout. Reads that land in a buffer, and presence probes, use cacheReadTimeoutForSize, the read-side twin of cacheWriteTimeoutForSize: a 30s floor plus one second per MiB, capped at the server WriteTimeout (5m); probes get the floor. Reads whose sink is the client (the large streamed whole-body serve, serveRangeFromCache, streamBlockRangeSequential) are paced by that client, so a size-scaled bound would cut off a slow-but-progressing client earlier than the server does today; they use the flat cacheStreamReadTimeout (5m), which only restates the server's WriteTimeout. A shorter parent deadline still wins everywhere. Call sites: serveFromCache (buffered small body: sized; streamed large body: flat), serveRangeFromCache (flat), every block payload read through the new getBlockRangeStream seam (assembled, certified, pipelined, complete-from-blocks and post-fetch re-reads: sized; sequential direct-to-client: flat), and the presence probes through probeBlock (ensureBlocksCached, runBlockFetch, parquet footer) plus entryServable's body probe (floor). A timeout is an ordinary transient read error on every path: bodyGone and the block-stream salvage already treat context.DeadlineExceeded as not-evidence-of-eviction, so the entry is never invalidated, a committed block stream is completed from upstream exactly as for any other read error, and a pre-commit failure falls through upstream. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
[Medium impact] The PR appears safe to merge. SummaryAdds per-read deadlines to proxy cache reads.
No actionable issues found. Review used source inspection; tests were not run. Reviews (1) · Last reviewed commit: "fix(cache): bound each cache read with a..." · Reviewed by Greptile |
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
A stalled remote peer read (
GetStream,GetRangeStream, including the byte-zero existence probes) held a request until the client disconnected or the server's 5-minuteWriteTimeoutfired; there was no per-read deadline on cache reads.Every cache read in the proxy package now runs under a
context.WithTimeoutchosen by what consumes the bytes:cacheReadTimeoutForSize: a 30-second floor plus one second per MiB, capped at 5 minutes; probes get the floor.serveRangeFromCache, the sequential block stream) use a flat 5 minutes, equal to the serverWriteTimeout. The client paces those reads, so a size-scaled bound would cut off slow clients; the flat cap only restates the bound the server already enforces.A deadline from either bound is an ordinary transient read error:
bodyGonestays false so nothing is invalidated; pre-commit reads fall through to upstream; committed block streams take the existing byte-exact remainder salvage. No function signatures or configuration change.Replaces #222, whose 242-line idle watchdog, per-write CAS and new config key are not adopted.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
Note
Medium Risk
Touches all GetObject cache-serve and block-assembly paths with new deadlines; mis-tuning could cause extra upstream fallthrough, but timeouts are explicitly non-invalidating and client-paced streams keep the server WriteTimeout cap.
Overview
Bounds every proxy cache read with a per-operation
context.WithTimeout, so a stalled remote peer gRPC read no longer holds requests until the client disconnects or the server’s 5-minuteWriteTimeout.Buffered reads and probes (small bodies, block assembly slices,
BodyExistsErr/ block presence checks) usecacheReadTimeoutForSize: a 30s floor plus one second per MiB, capped at 5 minutes. Reads whose sink is the HTTP client (large whole-body streams, range streams, sequential block streaming) use a flatcacheStreamReadTimeout(5 minutes, aligned withWriteTimeout) so slow clients are not cut off by size-scaled limits.Block cache paths consolidate on
getBlockRangeStreamandprobeBlock; parquet footer probing switches fromBlockExiststoprobeBlockso probe stalls surface as errors, not “absent.” Timeouts are treated as transient (existingbodyGone/ block salvage behavior): pre-commit paths fall through to upstream without invalidating metadata.Adds
cache_read_timeout_test.gocovering stalled whole-body and block-probe fallthrough, and that client-paced streams are not canceled by the short size-scaled deadline.Reviewed by Cursor Bugbot for commit 3627ecd. Bugbot is set up for automated code reviews on this repo. Configure here.