8484 loop {
8585 let database_key_index = self . database_key_index ( id) ;
8686
87- crate :: tracing:: debug!(
88- "{database_key_index:?}: maybe_changed_after(revision = {revision:?})"
89- ) ;
87+ let _span = crate :: tracing:: info_span!(
88+ "maybe_changed_after" ,
89+ ?revision,
90+ query=?database_key_index
91+ )
92+ . entered ( ) ;
9093
9194 // Check if we have a verified version: this is the hot path.
9295 let memo_guard = self . get_memo_from_table_for ( zalsa, id, memo_ingredient_index) ;
@@ -141,7 +144,7 @@ where
141144 ) -> Option < VerifyResult > {
142145 let database_key_index = self . database_key_index ( key_index) ;
143146
144- let _claim_guard = match self . sync_table . try_claim ( zalsa, key_index, true ) {
147+ let _claim_guard = match self . sync_table . try_claim ( zalsa, key_index, false ) {
145148 ClaimResult :: Claimed ( guard) => guard,
146149 ClaimResult :: Running ( blocked_on) => {
147150 blocked_on. block_on ( zalsa) ;
@@ -175,10 +178,8 @@ where
175178
176179 // If `validate_maybe_provisional` returns `true`, but only because all cycle heads are from the same iteration,
177180 // carry over the cycle heads so that the caller verifies them.
178- if old_memo. may_be_provisional ( ) {
179- for head in old_memo. cycle_heads ( ) {
180- cycle_heads. insert_head ( head. database_key_index ) ;
181- }
181+ for head in old_memo. cycle_heads ( ) {
182+ cycle_heads. insert_head ( head. database_key_index ) ;
182183 }
183184
184185 return Some ( if old_memo. revisions . changed_at > revision {
@@ -467,7 +468,7 @@ where
467468 match cycle_head {
468469 TryClaimHeadsResult :: Cycle {
469470 head_iteration_count,
470- current_iteration_count,
471+ memo_iteration_count : current_iteration_count,
471472 verified_at : head_verified_at,
472473 } => {
473474 if head_verified_at != verified_at {
@@ -487,7 +488,7 @@ where
487488 true
488489 }
489490
490- crate :: tracing:: trace !(
491+ crate :: tracing:: info !(
491492 "{database_key_index:?}: validate_same_iteration(memo = {memo:#?})" ,
492493 memo = memo. tracing_debug( )
493494 ) ;
@@ -506,6 +507,15 @@ where
506507 return false ;
507508 }
508509
510+ // Always return `false` if this is a cycle initial memo (or the last provisional memo in an iteration)
511+ // as this value has obviously not finished computing yet.
512+ if cycle_heads
513+ . iter ( )
514+ . all ( |head| head. database_key_index == database_key_index)
515+ {
516+ return false ;
517+ }
518+
509519 validate_same_iteration_cold ( zalsa, zalsa_local, cycle_heads, verified_at)
510520 }
511521
0 commit comments