summaryrefslogtreecommitdiffstats
path: root/src/simtest/holding.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-18 20:39:21 +0000
committertv <tv@krebsco.de>2026-11-18 21:42:25 +0100
commit43a6de3dc17123cbe35ff99fac283419fef3cf63 (patch)
tree461bad59e1c23638ebfa28e8c7c6f0e3bb9088d3 /src/simtest/holding.rs
parent5d26bfd64ee01ad921daf56005641518d398cb4b (diff)
simtest: b takes what it reads before the event its store stops at
b, started again with nothing, reads the new epoch's events by their IDs: what comes before the version event and isn't built on it, it takes, as its history takes it, and stops only there. The write put meanwhile a and c hold back, as b did before its restart, all stopped before it came; b, started again, may take it: the simulation waits for b to have it either way.
Diffstat (limited to 'src/simtest/holding.rs')
-rw-r--r--src/simtest/holding.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/simtest/holding.rs b/src/simtest/holding.rs
index 74086e2..12dac23 100644
--- a/src/simtest/holding.rs
+++ b/src/simtest/holding.rs
@@ -1144,11 +1144,12 @@ fn stopped(node: &AppState) -> Option<Id> {
read(node, |store| store.stopped().map(|(id, ..)| *id)).flatten()
}
-/// Whether `node`'s store holds back every event of `ids`.
-fn holds_back(node: &AppState, ids: &[Id]) -> bool {
+/// Whether `node`'s store holds back every event of `ids`, or, `taken_too`, holds it.
+fn holds_back(node: &AppState, ids: &[Id], taken_too: bool) -> bool {
read(node, |store| {
let held: BTreeSet<Id> = store.held_back().into_iter().map(|(id, _)| id).collect();
- ids.iter().all(|id| held.contains(id))
+ ids.iter()
+ .all(|id| held.contains(id) || (taken_too && store.holds(id)))
}) == Some(true)
}
@@ -1156,7 +1157,8 @@ fn holds_back(node: &AppState, ids: &[Id]) -> bool {
/// writes it: every node stops there, and holds back what is put meanwhile. A compaction
/// leaves none of it out: the new document holds that event and what came after. c, away
/// meanwhile, rejoins the new epoch and stops there too, and so does b, started again with
-/// nothing. Their operators have them drop that event: they take again, all alike.
+/// nothing, having taken what it read before that event, by its ID, and not built on it.
+/// Their operators have them drop that event: they take again, all alike.
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn a_stopped_store_keeps_what_it_holds_back_through_a_remake_and_a_rejoin() {
let sim = Sim::with_identity(98);
@@ -1196,7 +1198,7 @@ async fn a_stopped_store_keeps_what_it_holds_back_through_a_remake_and_a_rejoin(
sim.wait_until("a and b hold it back", LONG, move || async move {
all[..2]
.iter()
- .all(|node| holds_back(node, &[at, meanwhile]))
+ .all(|node| holds_back(node, &[at, meanwhile], false))
})
.await;
compact(&nodes[0]).await;
@@ -1208,7 +1210,7 @@ async fn a_stopped_store_keeps_what_it_holds_back_through_a_remake_and_a_rejoin(
}
for node in &nodes[..2] {
assert_eq!(stopped(node), Some(at));
- assert!(holds_back(node, &[meanwhile]));
+ assert!(holds_back(node, &[meanwhile], false));
}
sim.net.bring_up("c");
@@ -1220,7 +1222,7 @@ async fn a_stopped_store_keeps_what_it_holds_back_through_a_remake_and_a_rejoin(
c.local_epoch().generation == 1
&& c.is_ready().await
&& stopped(c) == Some(at)
- && holds_back(c, &[meanwhile])
+ && holds_back(c, &[meanwhile], false)
},
)
.await;
@@ -1235,7 +1237,7 @@ async fn a_stopped_store_keeps_what_it_holds_back_through_a_remake_and_a_rejoin(
b.local_epoch().generation == 1
&& b.is_ready().await
&& stopped(b) == Some(at)
- && holds_back(b, &[meanwhile])
+ && holds_back(b, &[meanwhile], true)
},
)
.await;