aboutsummaryrefslogtreecommitdiffstats
path: root/src/document/replica.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 13:19:04 +0100
committertv <tv@krebsco.de>2026-11-01 13:19:04 +0100
commit7a5a7408179c5fe9943bd2ce60295e86f1afaa40 (patch)
tree166284a6b05f1f3e5d5166c38eda33088ae5461b /src/document/replica.rs
parentb4aa16f2a3c3f9dc0d4eb6e7399bd7ffe269d669 (diff)
document: reject writes during rejoin
Diffstat (limited to 'src/document/replica.rs')
-rw-r--r--src/document/replica.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/document/replica.rs b/src/document/replica.rs
index 27c81ad..61f2b3b 100644
--- a/src/document/replica.rs
+++ b/src/document/replica.rs
@@ -113,6 +113,12 @@ pub(crate) struct Replica {
/// run: messages carry it, so a late one can't flip a peer's view of our epoch back.
pub(crate) epoch_seq: u32,
pub(crate) doc: Document,
+ /// Whether writes go in (`AppState::mutate_doc`). False while a rejoin syncs a fresh
+ /// document: a write would land in a document the epoch's snapshot hasn't reached
+ /// yet, or be thrown away with it if the rejoin is abandoned. Cleared and set again
+ /// in the same lock as the swap (`Host::switch_epoch`), so no write checked
+ /// before a swap lands after it.
+ pub(crate) writable: bool,
heads: Vec<ChangeHash>,
stamp: watch::Sender<Stamp>,
}
@@ -138,6 +144,7 @@ impl Replica {
epoch,
epoch_seq: 0,
doc,
+ writable: true,
heads: Vec::new(),
stamp,
};