Repository navigation
fix: count only verified copies and pass over targets that stop confirming them - #175
Merged
Merged
Conversation
A replication policy needs to know which blocks of a file a peer holds before it counts that peer as a copy, and nothing on the wire carried that. The new holdings capability domain (wire tag 4) adds HoldingsRequest (type 24) and HoldingsResponse (type 25): per path, the peer's version vector, total and held blocks and its last fetch error, plus a fetched-block progress counter. A node sends them only to a peer that advertised the domain, and an older decoder drops the unknown domain tag, so peers that predate it interoperate unchanged. CapabilityDomain moves into protocol/domain.rs to keep protocol.rs under the source-length cap. The frame and handshake conformance vectors and node-protocol.md cover the new frames. The sync engine answers holdings requests from its index and block store behind the same read gate as block requests, counts the blocks it fetches, and keeps each path's last fetch error. BlockHolder::peer_holdings answers Complete only when the peer has every block of the version this node holds, and records the confirmation in the index (migration 8, peer_copies), so it is answered from the record after a restart and asked again only once the file changes. HolderBlocks gains the fetch error and a cache flag, so complete_holders and degraded never count a cache's blocks as a copy, and Backend gains replication_status for a backend that places copies by policy.
…led targets Placement counted a named, connected machine as holding a file without knowing it held any block, so a named store that never fetched (a full disk, a persistent fetch error, a pass that never reached the file) left a file at one real copy while every node reported nothing under-replicated, and a cache could evict the last real copy. A machine now counts only once it has answered the holdings exchange with every block of the current version. under_replicated lists files below min_copies verified copies, or missing a must_hold copy, with each one's verified holders and its pending ones (blocks so far and cause). A target owing copies whose fetched-block counter does not move for IDLE_PASSES_BEFORE_PROMOTION consecutive passes, that reports the same fetch error as often, or that cannot answer, is treated as down for those files: every node computes the same promotion, so the next-ranked target names itself and fetches with no coordinator. A stalled target is asked again with exponential backoff and is named again once it confirms or moves. Cache eviction uses the same verified count. Each pass's counts are kept as the backend's replication_status and logged when the number of under-replicated files changes, and path_holdings lists the copies other machines confirmed, so one node shows every verified copy.
GET /v1/folders/{folder}/replication returns the last placement pass's
verified counts (files meeting min_copies, each under-replicated file with
its verified and pending holders, stalled targets and promoted files) under
status:read, and 404 for a backend that places no copies.
verify now reads each host's /replication and fails while any file is under min_copies verified copies, printing the pending holders, their block counts and causes, and the stalled targets. complete_stores skips holders flagged as caches.
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.
Fixes #140. Refs #57, #58.
Composite placement counted a named, connected machine as a copy of a file without knowing it held any block. In the composite acceptance run every node logged
under_replicated: []while 8 files sat at one real copy, and a named store that never completes (full disk, persistent fetch error, a pass that never reaches the file) would have left them there for good. A cache could also evict the last real copy on the same assumption.Verified copies. A machine now counts as a copy only once it has said, over a new holdings exchange, that it holds every block of the version this node holds. The P2P backend records each confirmation in its index against that version (migration 8,
peer_copies), so counts survive a restart without asking again and an edit makes every peer prove its copy afresh. A cache's blocks are never counted (HolderBlocks.cache), socomplete_holders/degradedare honest from any one node.Promotion. Each holdings answer carries the peer's count of blocks fetched since it started. A named target owing copies whose count does not move for
IDLE_PASSES_BEFORE_PROMOTION(2) consecutive passes, that reports the same fetch error as often, or that cannot answer at all, is treated as down for those files. Every node computes that the same way, so the next-ranked target finds itself named and fetches, with no coordinator. The bound counts passes and blocks, not time: one idle pass can be a healthy target between files of its serial walk, two in a row means it fetched nothing for a whole pass. A stalled target is reported once per cause change, asked again with exponential backoff (2, 4, ... 64 passes) and named again once it confirms or moves; a stalledmust_holdtarget stays named and counted short while the copies are filled from the ranking.Reporting.
under_replicatedlists files belowmin_copiesverified copies (or missing amust_holdcopy), each with its verified holders and its pending ones (blocks so far, cause). Each pass's counts are kept asBackend::replication_status, served atGET /v1/folders/{folder}/replication(status:read), logged at info when the number of short files changes, and checked byscripts/composite-acceptance.py verifyon every host.path_holdingsnow includes the copies other machines confirmed, so one host shows every verified copy. Cache eviction uses the same verified count.Protocol compatibility. A new capability domain
holdings(wire tag 4) withHoldingsRequest(24) andHoldingsResponse(25), protocol version unchanged at 1 since no existing frame changes meaning. A node sends the frames only to a peer that advertised the domain, and a decoder that predates it drops the unknown domain tag (handshake_drops_unknown_domain_discriminant), so old peers never see an unknown frame and keep syncing content as before. An old peer's copies cannot be verified, so it is reported stalled with that cause and never counted. Answers sit behind the same read gate as block requests. Conformance vectors anddocs/node-protocol.mdcover both frames and the extended negotiation.Tests (all counted in passes and blocks): a named peer that connects but never fetches stays listed under-replicated through the bound, then the next store is promoted and fetches it; a peer holding part of a file is not counted; verified counts survive a restart with the exchange turned off afterwards; an old peer syncs but is never counted; a cache keeps blocks no store has confirmed and evicts them once one has. With the verified filter mutated to count any answering peer, four of these go red.