Repository navigation
Description
Summary
When a node joins, the node it joined answers the membership sync with a cache_warmup message listing the
keys it holds, freshest first. The joiner records them as ownership claims, so it starts knowing where
the cluster's working set lives instead of discovering it one cache miss at a time.
Two things in the plan above could not be implemented as written
1. cache.Warmup(keys) is the S3 traffic this feature exists to avoid. MultiLevelCache.Warmup
(multilevel.go:301) is one GetObject per key. Calling it on a warmup message would have a joining node
issue a whole-object GET for every key in it — turning cold-start cost into a burst of egress before the node
serves a single read, and gigabytes of it on a large-object workload. So the acceptance criterion "hit rate
for warmed keys is 100% before any S3 request" cannot pass against that function under any bound:
Warmup is the S3 request. What the criterion was reaching for is delivered by recording the
announcements into the ownership map, which costs nothing and is what the joiner needs — the bytes come from
S3 when a read actually wants them, as in #142.
2. "Max 256 entries" does not bound a UDP payload. Measured against the real seal path at the default
8192-byte limit, with 52-character keys shaped like a research bucket's: 256 announcements seal to 65631
bytes, 8× over. Every warmup datagram would be refused at the socket and a joining node would warm nothing
at all, with the failure visible only in whatever the sender did with the error. 31 fit at that key
length — and 31 is not a constant to write down instead, because it moves with key length. A count cannot
bound a byte limit.
What was implemented
MessageTypeCacheWarmupandCacheWarmupMessage{Keys []types.KeyAnnouncement}, dispatched from
handleIncomingMessage. Full announcements rather than bare keys: the ETag is what makes an entry
actionable, per A2-2: Implement AnnounceKey and QueryKeyOwnership in coordinator #140.handleJoinMessagesends the warmup after the membership sync, on the same goroutine — a node that
knows which keys are hot but not who its peers are cannot act on either, and sequential sends keep the two
off the same socket at once while the joiner's receive loop is still starting.Coordinator.selfAnnounced, a second map besideannouncements, recorded byAnnounceKey. It has to
be separate:announcementsanswersQueryKeyOwnership, which is asked because this node's cache
missed, so a self-claim there is a holder guaranteed not to hold. And it cannot be replaced by
enumerating the cache —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. Same mutex, same TTL, same bound, and the
existing sweep covers it (the half that would otherwise leak silently, sincerecentHoldingsfilters
expired entries on read).Coordinator.recentHoldings(limit)— freshest first, expired excluded. Freshest-first is what makes a
truncated message the useful half rather than an arbitrary one.- Bounded by measured sealed bytes, reusing the shape of
syncChunkFits: the chunk is grown one entry at
a time and the whole message sealed to check, so the envelope, the MAC and the base64 expansion are all
measured rather than estimated. A join sends at mostmaxWarmupDatagrams= 4 (~124 keys at that density),
which bounds the burst a joining node receives, and logsheld_backwhen it truncates — a bound that
silently truncates reads as "everything was sent". - The joiner records each entry through
recordAnnouncement, so the self-claim refusal, per-node
replacement, map bound, local timestamp and empty-ETag refusal all apply unchanged; batching is not a way
around any of them. The envelope's sender overrides each entry's NodeID, so one member cannot populate
a joiner's whole ownership map with fabricated holders.
Acceptance Criteria
- A real join over loopback UDP warms the joiner: it learns holders it was never told about
individually, with NodeID, ETag, Size and Length all asserted. The joiner is removed from the sender's
memberlist before anything is announced, so the join is the only channel by which it could learn
— the first version cleared the map after announcing and passed withrecordSelfHoldingdeleted
entirely, because delivery is asynchronous - Every chunk fits a sealed datagram, measured — 256 candidates packed, the sealed message compared
tomax_gossip_packet, and the payload unmarshaled to confirm it carries what was counted - The bound holds at a non-default
max_gossip_packet(halved after construction) - The entries-per-datagram count varies with key length, which is why no constant would be right
- An announcement too large to fit alone is reported (Warn — a misconfiguration, not a lost packet) and
the rest are still attempted - A node holding nothing sends no warmup message
- A burst of 2000 held keys produces at most
maxWarmupDatagramsdatagrams, and not zero -
recentHoldingsexcludes peers' claims, orders freshest-first, excludes expired claims, and replaces
an earlier version of the same key; the map is bounded; the sweep clears both maps - The envelope's sender wins over an entry's own NodeID; unusable entries and a malformed payload are
discarded -
go test -race ./internal/distributed/...passes, with and without-tags=distributed; every guard
mutation-verified
Activity
scttfrdmn commentedon Jul 30, 2026
Note from the v0.10.0 review — two blockers in the current design
1. The gossip packet is far too small for the proposed announcement batch.
MaxGossipPacketdefaults to 1024 bytes (internal/distributed/cluster.go). A batch of 256KeyAnnouncements cannot fit — S3 keys alone can be up to 1024 bytes each. Either the defaultneeds raising (with MTU fragmentation considered, since gossip is UDP), or announcements need
chunking across multiple packets, or key digests should be sent instead of full keys.
2. The acceptance criterion contradicts what
Warmupdoes. The criterion "100% hit ratebefore any S3 request" cannot hold, because
MultiLevelCache.Warmup(
internal/cache/multilevel.go) populates the cache by fetching from the backend:One S3
GetObjectper key. It also no-ops entirely when no backend is configured. SoWarmupis the S3 traffic the criterion is trying to avoid.
For warming to avoid S3 it would have to pull cached bytes from a peer over the network — which
is a different feature than the one
Warmupimplements today, and a larger one. Worth decidingwhich is intended before starting: peer-to-peer cache transfer, or accept the S3 fetches and
restate the criterion as "warm before first user request."
Note also that
NodeInfo's cache statistics fields are never populated (see #132), so awarming implementation has no data to make peer-selection decisions from yet.
scttfrdmn commentedon Aug 2, 2026
Correction: the 256-entry bound overflows the default packet, and the acceptance criterion contradicts
WarmupRe-verified against
main. Two problems, one of which makes the headline acceptance criterion unachievable.1.
MaxGossipPacketdefaults to 1024 bytes (internal/distributed/cluster.go:158-159), and that is the size of the read buffer:gossip.go:272doesmake([]byte, gp.config.MaxGossipPacket). A 256-entryCacheWarmupMessagecannot fit. Even at an implausibly small 20 bytes of JSON per announcement — a key, a node ID, a timestamp, and the surrounding{}/quotes/commas — 256 entries is >5 KB, and realistic S3 keys (genomics/sample-42/reads.bam) put it above 15 KB. The receive path does not reassemble, so an oversized datagram is silently truncated to 1024 bytes and then fails to unmarshal. The issue's own bullet says the 256 cap exists "to bound UDP payload"; it does not bound it to anything the receiver will accept.Options, in order of preference:
MaxGossipPacketminus envelope overhead, and send what fits. This is correct at any configured packet size and needs no new default.MaxGossipPacketto something above the practical MTU story (a 1024-byte default is small even for membership gossip) and keep a byte-based fill. Note that raising it past ~1472 means IP fragmentation on standard Ethernet, which is a reliability regression for the messages that already work.2. "
cache.Stats().HitRatefor warmed keys is 100% before any S3 request" is contradicted by the implementation.MultiLevelCache.Warmup(internal/cache/multilevel.go:301-320) is:Warmupis one full-object S3 GET per key. So the criterion as written can never pass, and worse, the feature as specified does the opposite of what the issue claims: a joining node handed 256 keys issues 256 whole-object GETs at join time — a cold-start cost spike, not an avoided one, and on a large-object workload potentially gigabytes of egress before the node serves a single read.That does not sink the feature, but it changes what it is. Either:
Warmup(keys)call.Either way the acceptance criterion should assert where the bytes came from (S3 request count, peer request count), not a hit-rate number. A hit rate of 100% is also what you get from a cache that was warmed by 256 S3 GETs, which is the outcome this issue exists to avoid.
3.
GetRecentAnnouncementsdoes not exist yet — zero hits for it orKeyAnnouncementrepo-wide. Correctly listed as a dependency on #140; noting it so nobody readscluster.Get...as an existing call.Accurate as written:
Warmupdoes exist onmultilevel.gowith the assumed signature; the empty-map-sends-nothing criterion is good; bounding the message is the right instinct even though the stated bound is wrong.feat(types)!: cache coordination on DistributedCoordinator, with stub…
scttfrdmn commentedon Aug 9, 2026
"Max 256 entries per warmup message to bound UDP payload" does not bound it. 256
KeyAnnouncements do not fit a gossip datagram — not at the default limit, and not within a factor of seven of it.Measured with the real
sealpath (auth.go:199) and representative entries — a plausible S3 key, a hostname-shapedNodeID, a quoted ETag, a size, a timestamp, an offset and a length — againstdefaultMaxGossipPacket = 8192(cluster.go:189):So a 256-entry warmup message is refused outright by the
MaxGossipPacketguard atgossip.go:1246. Not truncated, not fragmented —sendMessagereturns an error and nothing goes on the wire. A node joining a cluster would warm nothing at all, and the only trace would be whatever the caller does with that error.And 32 is not a constant to write down instead. It is a function of key length: these keys were ~50 characters, and a deployment with long prefixes gets fewer, while one with short keys gets more. Any fixed number is either wasteful or wrong depending on the bucket, which is the real lesson — a count cannot bound a byte limit.
syncChunkFitsis the mechanism to reusegossip.go:1460already solves exactly this shape for node sync, and solves it the right way:It seals a candidate chunk and measures it, rather than estimating from a size ratio. Chunk the warmup announcements the same way: add entries until the sealed message would exceed
MaxGossipPacket, then start a new one. That is correct at any key length, correct ifMaxGossipPacketis reconfigured, and correct if a field is ever added toKeyAnnouncement— none of which a256survives.There is also a precedent for asserting the bound rather than trusting it:
TestNewClusterManager_DefaultMaxGossipPacketHoldsAThreeNodeSync(cluster_test.go:143) exists because a limit of 1024 could not carry the smallest cluster needing a quorum, and its comment notes that a test comparing the constant to8192would have passed on the broken value. The equivalent here is a test that chunks a realistic announcement set and asserts every chunk seals under the limit.Related: #399 measures the same guard from the other side — a remote operation's response can carry only 5802 bytes of object before the sealed datagram is refused (38.9% inflation from base64 plus envelope plus MAC, not the ~33% base64 alone suggests). Same guard, same lesson: measure the sealed length, never estimate it.