From ac4d8c0d28a96bd7e69b763374f7d3028440219f Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 11:56:08 +0000 Subject: held: the store's worker reads a document only while it is writable A rejoin makes the node's document writable again only as it ends, in the lock of the swap, once the node checked the epoch (`Holding::follows`) and follows it or gives it up. The store's worker reads nothing, and writes nothing, while the document isn't writable, checked in the lock it reads under. Whether a rejoin runs isn't enough: its state is taken up for its last checks, while the epoch's document is still the node's, and a store started from that document would keep the checkpoint it read there, and put again what it took into the document the node goes back to. --- src/federation/held.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/federation/held.rs b/src/federation/held.rs index 7f68424..985ff45 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -906,19 +906,19 @@ pub(crate) async fn run_worker(state: crate::state::AppState) { } else { Vec::new() }; - // A rejoin's document isn't the node's until it follows the epoch - // (`Holding::follows`): nothing of it is read, nor written on it, till then. - let rejoining = state.remake.is_rejoining(); let read = tokio::task::spawn_blocking(move || { - if rejoining { - return (false, Vec::new(), Vec::new()); - } - holding.look(&refused); - // Read from the document under its lock; taken without it. + // Read from the document under its lock; taken without it. A rejoin's + // document isn't the node's until it follows the epoch (`Holding::follows`) + // and the rejoin ends, which makes it writable again, in the lock of the + // swap: nothing of it is read, nor written on it, till then. let unread = { let replica = doc.blocking_read(); + if !replica.writable { + return (false, Vec::new(), Vec::new()); + } holding.unread(&replica.doc, replica.epoch_seq) }; + holding.look(&refused); if let Some(unread) = unread { holding.read(unread); } -- cgit v1.3.1