aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/held.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 11:56:08 +0000
committertv <tv@krebsco.de>2026-11-17 13:01:18 +0100
commitac4d8c0d28a96bd7e69b763374f7d3028440219f (patch)
treed8476ef58d9a8d81d8212276e71655cae49b5962 /src/federation/held.rs
parentfd21b989604ac4bc604c03c749a67fdb80af6287 (diff)
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.
Diffstat (limited to 'src/federation/held.rs')
-rw-r--r--src/federation/held.rs16
1 files 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);
}