Repository navigation
feat(cluster): warm a cold read on a peer's evidence, and a joiner on a join (#142, #143) - #404
Merged
Merged
Conversation
… a join (#142, #143) A cache miss now asks the cluster who holds the key and, when a peer holds a range reaching past what was just read, reads ahead to the end of that range from S3 — capped at 4 MiB per miss. And a node answering a join follows the membership sync with the keys it holds, so the joiner starts knowing where the cluster's working set lives. Both issues specified something the transport cannot do, and both are implemented as the rescope rather than as written. #142 planned to fetch the bytes from the peer over ExecuteOperation. A gossip datagram carries 5802 bytes of object at the default limit, so a 128 KiB read is 21x over and fails as a 30-second timeout on the requesting host (#399). What a peer's claim is actually evidence of is that the key is hot in this cluster — the one thing a cold node cannot learn on its own — which is worth acting on even when the bytes still come from S3. #143 specified "max 256 entries per warmup message to bound UDP payload" and cache.Warmup(keys) on receipt. Measured: 256 announcements with 52-character keys seal to 65631 bytes against the 8192-byte default, 8x over, so every warmup datagram would be refused at the socket and a joiner would warm nothing. 31 fit, and 31 is not a constant to hardcode either — it moves with key length, which TestMarshalWarmupChunk_TheCountVariesWithKeyLength asserts. So the chunk is grown one entry at a time and sealed to check, reusing syncChunkFits's shape. MultiLevelCache.Warmup is one GetObject per key, so calling it would turn cold-start into an egress burst; recording the announcements delivers what the "100% hit rate before any S3 request" criterion was reaching for, and costs nothing. A claim is acted on only at the version this node is reading. A holder's range describes the object it cached; against another version the object may have a different length entirely. A mismatch, or no known version on either side, warms nothing — the same fail-closed rule announceCached applies in the other direction. selfAnnounced is a second map beside announcements, and the separation is load-bearing: announcements answers QueryKeyOwnership, which is asked because this node's cache missed, so a self-claim there is a holder guaranteed not to hold. The cache cannot be enumerated instead — types.Cache stores bytes with no version beside them. The existing sweep now covers both maps; the second is the half that would have leaked silently, since recentHoldings filters on read. read_ahead.enabled: false suppresses the warm and the ownership query both, rather than asking peers once per cache miss and discarding the answer. Every guard is mutation-verified: each of thirteen deliberate breakages fails a named test. Two of them initially survived and both were test defects — TestJoinWarmsTheJoiner cleared the joiner's map after announcing, which races asynchronous delivery and passed with recordSelfHolding deleted entirely, and a redundant empty-holdings guard duplicated the send loop's own break. Closes #142 Closes #143
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.
Closes #142, closes #143. The last two issues in the v0.13.0 warming chain.
What this does
A cache miss asks the cluster who holds the key. If a peer holds a range reaching past what was just read, this node reads ahead to the end of that range — from S3, capped at 4 MiB per miss. And a node answering a join follows the membership sync with a
cache_warmupmessage listing the keys it holds, which the joiner records as ownership claims.Both issues specified something the transport cannot do
#142 planned to fetch the bytes from the peer via
ExecuteOperation(&types.ReadOp{...}). A gossip datagram carries 5802 bytes of object at the default limit, so a 128 KiB kernel read is 21× over and fails as a 30-second timeout on the requesting host (#399 made that failure honest, which is what made this rescope possible). What a peer's claim is actually evidence of is that the key is hot in this cluster — the one thing a cold node cannot learn on its own — and that is worth acting on even when the bytes still cost an S3 read.PeerFetchTimeoutis deliberately not added: it would describe a code path that does not exist.#143 specified "max 256 entries per warmup message" and
cache.Warmup(keys)on receipt. Neither works:syncChunkFits's shape. A count cannot bound a byte limit.MultiLevelCache.Warmupis oneGetObjectper key, so calling it on a warmup message turns cold-start into an egress burst. The criterion "100% hit rate before any S3 request" cannot pass against it under any bound —Warmupis the S3 request. Recording the announcements delivers what that criterion was reaching for, and costs nothing.Both issue bodies have been rewritten to match.
Design notes worth a reviewer's attention
A claim is acted on only at the version this node is reading. A holder's range describes the object it cached; against another version the object may have a different length entirely, so warming on it fetches bytes chosen by a claim about something else. A mismatch — or no known version on either side — warms nothing, which costs exactly the read the application asked for. Same fail-closed rule
announceCachedapplies in the other direction.selfAnnouncedis a second map besideannouncements, and the separation is load-bearing.announcementsanswersQueryKeyOwnership, which is asked because this node's cache missed, so a self-claim there is a holder guaranteed not to hold, returned in place of a peer that does. And the cache cannot be enumerated instead:types.Cachestores bytes with no version beside them, so the only record of what this node holds and at which version is what it announced. The existing sweep now covers both maps — the second is the half that would have leaked silently, sincerecentHoldingsfilters expired entries on read.The warm goes through the prefetch queue, so it inherits EOF clamping, skipping what is cached, standing off in-flight reads, and flight-sharing. It does not touch the read pattern: another node's reads must not decide whether this reader looks sequential. It is called from
FileHandle.Readand never fromfetchUncached, so a warm's own GET cannot query ownership and queue another — a warm cannot feed itself and walk the object.read_ahead.enabled: falsesuppresses the warm and the ownership query both, rather than asking peers once per cache miss and discarding the answer.Verification
go test -race ./...— clean, whole repo, not-shortgo test -race -tags=distributed ./internal/distributed/...— cleango build ./...,gofmt -l,go vet ./internal/...,golangci-lint run --new-from-merge-base=origin/main— cleaninternal/distributed/cache_warmup_test.go, 14 ininternal/fuse/warm_test.goMutation-verified, thirteen guards, each breakage failing a named test. Two initially survived and both were test defects, now fixed:
TestJoinWarmsTheJoinercleared the joiner's ownership map after announcing. Delivery is asynchronous on the joiner's receive goroutine, so a broadcast still in flight lands after the clear — that version passed withrecordSelfHoldingdeleted entirely. The joiner is now removed from the sender's memberlist before anything is announced, and the test asserts zero announcements arrived, so the join is provably the only channel. It also surfaced thattestConfigadvertises127.0.0.1:0, which is a request for a free port rather than an address anything can reply to.sendCacheWarmupduplicated the send loop's ownbreak, so no test could distinguish them. Removed, with the reasoning recorded where the remaining check lives.The #142 assertions are on decisions and on effects: most read the prefetch queue with no workers draining it (deterministic, per
read_path_test.go's hard-won precedent), butTestWarmingReallyFetchesTheRangeruns a real worker and asserts the warmed range lands in the cache with the right bytes and came from S3 — queue assertions alone would pass against awarmthat queued onto a channel nothing read.