Skip to content

Commit 0756af5

Browse files
committed
Fix cycle_head_kinds to always return provisional for memos that aren't verified final (They should be validated by validate_same_iteration or wait for the cycle head
1 parent 0a608d8 commit 0756af5

File tree

2 files changed

+61
-50
lines changed

2 files changed

+61
-50
lines changed

src/function.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
pub(crate) use maybe_changed_after::VerifyResult;
12
use std::any::Any;
23
use std::fmt;
34
use std::ptr::NonNull;
4-
5-
pub(crate) use maybe_changed_after::VerifyResult;
5+
use std::sync::atomic::Ordering;
66

77
use crate::accumulator::accumulated_map::{AccumulatedMap, InputAccumulatedValues};
88
use crate::cycle::{CycleHeadKind, CycleHeads, CycleRecoveryAction, CycleRecoveryStrategy};
@@ -246,16 +246,7 @@ where
246246
fn cycle_head_kind(&self, zalsa: &Zalsa, input: Id) -> CycleHeadKind {
247247
let is_provisional = self
248248
.get_memo_from_table_for(zalsa, input, self.memo_ingredient_index(zalsa, input))
249-
.is_some_and(|memo| {
250-
match memo.cycle_heads().iter().as_slice() {
251-
[] => false,
252-
[head] => head.database_key_index == self.database_key_index(input),
253-
// If there are multiple cycle heads, we assume that the memo is still provisional.
254-
// This indicates that this memo is part of an outer cycle that should be awaited first.
255-
[..] => true,
256-
}
257-
258-
});
249+
.is_some_and(|memo| !memo.revisions.verified_final.load(Ordering::Relaxed));
259250
if is_provisional {
260251
CycleHeadKind::Provisional
261252
} else if C::CYCLE_STRATEGY == CycleRecoveryStrategy::FallbackImmediate {

tests/parallel/cycle_nested_deep.rs

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,21 @@ fn initial(_db: &dyn KnobsDatabase) -> CycleValue {
7474

7575
#[test_log::test]
7676
fn the_test() {
77-
shuttle::replay(
77+
// shuttle::replay(
78+
crate::sync::check(
7879
|| {
80+
tracing::info!("New run");
7981
let db_t1 = Knobs::default();
8082
let db_t2 = db_t1.clone();
8183
let db_t3 = db_t1.clone();
8284

83-
let t1 = thread::spawn(move ||
84-
{
85-
let _span =
86-
tracing::debug_span!("t1", thread_id = ?thread::current().id()).entered();
87-
let result = query_a(&db_t1);
88-
db_t1.signal(1);
89-
result
90-
});
85+
let t1 = thread::spawn(move || {
86+
let _span =
87+
tracing::debug_span!("t1", thread_id = ?thread::current().id()).entered();
88+
let result = query_a(&db_t1);
89+
db_t1.signal(1);
90+
result
91+
});
9192
let t2 = thread::spawn(move || {
9293
let _span =
9394
tracing::debug_span!("t2", thread_id = ?thread::current().id()).entered();
@@ -106,34 +107,53 @@ fn the_test() {
106107
let r_t3 = t3.join().unwrap();
107108

108109
assert_eq!((r_t1, r_t2, r_t3), (MAX, MAX, MAX));
109-
},
110-
111-
"
112-
9102fb12d0e0f3bef2bbecafd901000000000000802449922449922449922449922449922449
113-
9224499224499224499224499224499224499224499224499224499224499224499224499224
114-
4992244992244992244992244992244992244992244992244992244992244992244992244992
115-
2449922449922449922449922449922449922449922449922449922449922449922449922449
116-
9224499224499224499224499224499224499224499224499224499224499224499224499224
117-
4992244992244992244992244992244992244992244992244992244992244992244992244992
118-
2449922449922449922449922449922449922449922449922449922449922449922449922449
119-
9224499224499224499224499224499224499224499224499224499224499224499224499224
120-
4992244992244992244992244992244992244992244992244992244992244992244992244992
121-
2449922449922449922449922449922449922449922449922449922449922449922449922449
122-
9224499224499224499224499224499224499224499224499224499224499224499224499224
123-
4992244992244992244992244992244992244992244992244992244992244992244992244992
124-
2449922449922449922449922449922449922449922449922449922449922449922449922449
125-
9224499224499224499224499224499224499224499224499224499224499224499224499224
126-
4992244992244992244992244992244992244992244992244992244992244992244992244992
127-
2449922449922449922449922449922449922449922449922449922449922449922449922449
128-
9224499224499224499224499224499224499224499224499224499224499224499224499224
129-
4992244992244992244992244992244992244992244992244992244992244992244992244992
130-
2449922449922449922449922449922449922449922449922449922449922449922449922449
131-
9224499224499224499224499224499224499224499224499224499224499224499224499224
132-
4992244992244992244992244992244992244992244992244992244992244992244992244992
133-
2449922449922449922449922449922449922449922449922449922449922449922449922449
134-
9224499224499224499224499224499224499224499224499224499224499224499224499224
135-
499224499224499224499224499224499224812449922449922449922449922461dbb66ddbb6
136-
6ddbb66ddbb66ddbb66ddb3600
137-
"
110+
111+
tracing::info!("Complete");
112+
}, // ,
113+
// "
114+
// 9102ac21f5a392c8f88cc0a27300000000004092244992244992244992244992244992244992
115+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
116+
// 9224499224499224491248c23664dbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66d
117+
// dbb66ddbb66d9324499224499224499224499224499224499224499224499224494a92244992
118+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
119+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
120+
// 499224499224499224499224499224499224499224c91629dbb66ddbb66d922449922449d9b6
121+
// 6ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddb364992942449922449924892
122+
// 244992244992244992244992244992244992b429dab66ddbb66d4b922449922449b46ddbb66d
123+
// dbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb6
124+
// 6ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddb
125+
// b66ddbb66ddbb66ddbb66ddbb66ddbb66ddbb66ddb2449922449922449922449922449922449
126+
// 922449922449922449d2b66ddbb66ddbb66ddbb66ddbb66ddbb66ddb962c4992244992244992
127+
// 2449922449922449b66ddbb64d49922449922449922449922449922449922449922449922449
128+
// 922449922449924892244992244992244992246ddbb624499224499224499224499224499224
129+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
130+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
131+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
132+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
133+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
134+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
135+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
136+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
137+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
138+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
139+
// 244992244992244992244992244992244992489124499224498a244992244992244992244992
140+
// 2449922449922449922449922449922449922449922449922449529224499224492249922449
141+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
142+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
143+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
144+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
145+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
146+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
147+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
148+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
149+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
150+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
151+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
152+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
153+
// 9224499224499224499224499224499224499224499224499224499224499224499224499224
154+
// 4992244992244992244992244992244992244992244992244992244992244992244992244992
155+
// 2449922449922449922449922449922449922449922449922449922449922449922449922449
156+
// 922449922449922449922449922449922409
157+
// "
138158
);
139159
}

0 commit comments

Comments
 (0)