From 44a61c46160843d917a1da24bc8e364c5109960d Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 04:13:38 +0000 Subject: remake: holding a store, of two epochs decided for one, the lower ID In a swarm holding a store, of two epochs decided for one, by a coordinator that wrote two decisions or by remakes decided at once, a node follows the one with the lower ID, and a node on the other rejoins it, however many peers are on each (`docs/store.md`, Remakes): a node switches to the lower of two committed remakes of its epoch, follows the lowest of several newer epochs, and a ready node rejoins a lower one of its own generation that enough peers serve. --- src/remake/switch.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/remake/switch.rs') diff --git a/src/remake/switch.rs b/src/remake/switch.rs index 657b0f5..e56cd8c 100644 --- a/src/remake/switch.rs +++ b/src/remake/switch.rs @@ -117,6 +117,29 @@ async fn check(host: &H) { return catchup::check(host).await; } [(id, record)] => (id.clone(), record.clone()), + // Holding a store, of two epochs decided for one, the lower ID (`docs/store.md`, + // Remakes). + #[cfg(feature = "federation")] + several + if host + .read_doc(|doc| { + matches!( + crate::access::policy::of(doc), + crate::access::policy::Policy::Store(_) + ) + }) + .await => + { + let lowest = several + .iter() + .filter(|(_, record)| !record.contested) + .min_by_key(|(_, record)| record.committed_epoch().map(|epoch| epoch.id)); + let Some((id, record)) = lowest else { + error!("Decisions on these remakes disagree; not switching on my own"); + return catchup::check(host).await; + }; + (id.clone(), record.clone()) + } several => { // Majority voting prevents this; never guess which one is right. Peers // that did switch can still be followed. -- cgit v1.3.1