@@ -3,7 +3,7 @@ use crate::function::memo::Memo;
33use crate :: function:: sync:: ClaimResult ;
44use crate :: function:: { Configuration , IngredientImpl , VerifyResult } ;
55use crate :: zalsa:: { MemoIngredientIndex , Zalsa , ZalsaDatabase } ;
6- use crate :: zalsa_local:: QueryRevisions ;
6+ use crate :: zalsa_local:: { QueryRevisions , ZalsaLocal } ;
77use crate :: Id ;
88
99impl < C > IngredientImpl < C >
1818 #[ cfg( debug_assertions) ]
1919 let _span = tracing:: debug_span!( "fetch" , query = ?database_key_index) . entered ( ) ;
2020
21- let memo = self . refresh_memo ( db, zalsa, id) ;
21+ let memo = self . refresh_memo ( db, zalsa, zalsa_local , id) ;
2222 // SAFETY: We just refreshed the memo so it is guaranteed to contain a value now.
2323 let memo_value = unsafe { memo. value . as_ref ( ) . unwrap_unchecked ( ) } ;
2424
@@ -41,13 +41,16 @@ where
4141 & ' db self ,
4242 db : & ' db C :: DbView ,
4343 zalsa : & ' db Zalsa ,
44+ zalsa_local : & ' db ZalsaLocal ,
4445 id : Id ,
4546 ) -> & ' db Memo < C :: Output < ' db > > {
4647 let memo_ingredient_index = self . memo_ingredient_index ( zalsa, id) ;
4748 loop {
4849 if let Some ( memo) = self
4950 . fetch_hot ( zalsa, id, memo_ingredient_index)
50- . or_else ( || self . fetch_cold_with_retry ( zalsa, db, id, memo_ingredient_index) )
51+ . or_else ( || {
52+ self . fetch_cold_with_retry ( zalsa, zalsa_local, db, id, memo_ingredient_index)
53+ } )
5154 {
5255 return memo;
5356 }
@@ -84,11 +87,12 @@ where
8487 fn fetch_cold_with_retry < ' db > (
8588 & ' db self ,
8689 zalsa : & ' db Zalsa ,
90+ zalsa_local : & ' db ZalsaLocal ,
8791 db : & ' db C :: DbView ,
8892 id : Id ,
8993 memo_ingredient_index : MemoIngredientIndex ,
9094 ) -> Option < & ' db Memo < C :: Output < ' db > > > {
91- let memo = self . fetch_cold ( zalsa, db, id, memo_ingredient_index) ?;
95+ let memo = self . fetch_cold ( zalsa, zalsa_local , db, id, memo_ingredient_index) ?;
9296
9397 // If we get back a provisional cycle memo, and it's provisional on any cycle heads
9498 // that are claimed by a different thread, we can't propagate the provisional memo
98102 // That is only correct for fixpoint cycles, though: `FallbackImmediate` cycles
99103 // never have provisional entries.
100104 if C :: CYCLE_STRATEGY == CycleRecoveryStrategy :: FallbackImmediate
101- || !memo. provisional_retry ( zalsa, self . database_key_index ( id) )
105+ || !memo. provisional_retry ( zalsa, zalsa_local , self . database_key_index ( id) )
102106 {
103107 Some ( memo)
104108 } else {
@@ -109,6 +113,7 @@ where
109113 fn fetch_cold < ' db > (
110114 & ' db self ,
111115 zalsa : & ' db Zalsa ,
116+ zalsa_local : & ' db ZalsaLocal ,
112117 db : & ' db C :: DbView ,
113118 id : Id ,
114119 memo_ingredient_index : MemoIngredientIndex ,
@@ -161,7 +166,7 @@ where
161166 tracing:: debug!(
162167 "hit a `FallbackImmediate` cycle at {database_key_index:#?}"
163168 ) ;
164- let active_query = db . zalsa_local ( ) . push_query ( database_key_index, 0 ) ;
169+ let active_query = zalsa_local. push_query ( database_key_index, 0 ) ;
165170 let fallback_value = C :: cycle_initial ( db, C :: id_to_input ( db, id) ) ;
166171 let mut revisions = active_query. pop ( ) ;
167172 revisions. cycle_heads = CycleHeads :: initial ( database_key_index) ;
@@ -202,7 +207,7 @@ where
202207 && old_memo. may_be_provisional ( )
203208 && old_memo. verified_at . load ( ) == zalsa. current_revision ( )
204209 {
205- old_memo. await_heads ( zalsa) ;
210+ old_memo. await_heads ( zalsa, zalsa_local ) ;
206211
207212 // It's possible that one of the cycle heads replaced the memo for this ingredient
208213 // with fixpoint initial. We ignore that memo because we know it's only a temporary memo
@@ -227,7 +232,7 @@ where
227232
228233 let memo = self . execute (
229234 db,
230- db . zalsa_local ( ) . push_query ( database_key_index, 0 ) ,
235+ zalsa_local. push_query ( database_key_index, 0 ) ,
231236 opt_old_memo,
232237 ) ;
233238
0 commit comments