@@ -225,11 +225,22 @@ impl RefreshCoordinator {
225225 self . changed . notify_all ( ) ;
226226 }
227227 RefreshCoordinatorState :: Idle => { }
228- _ => {
228+ RefreshCoordinatorState :: Completing ( active ) => {
229229 // Mismatched key — another refresh owns this state. Log and
230230 // leave it alone; the owning refresh will clean up.
231231 error ! (
232- "force_complete_request called with mismatched key; current state not owned by caller"
232+ "force_complete_request called with mismatched key while coordinator was Completing; caller key: {:?}, active key: {:?}" ,
233+ key,
234+ active. key
235+ ) ;
236+ }
237+ RefreshCoordinatorState :: Running ( active) => {
238+ // Mismatched key — another refresh owns this state. Log and
239+ // leave it alone; the owning refresh will clean up.
240+ error ! (
241+ "force_complete_request called with mismatched key while coordinator was Running; caller key: {:?}, active key: {:?}" ,
242+ key,
243+ active. key
233244 ) ;
234245 }
235246 }
@@ -943,10 +954,10 @@ pub fn handle_refresh(context: Arc<Context>, id: u32, params: Value) {
943954 // (including begin_completion), force the
944955 // coordinator back to Idle so waiters are not
945956 // stuck forever.
946- let mut safety_guard = RefreshSafetyGuard :: new (
947- & context . refresh_coordinator ,
948- refresh_key . clone ( ) ,
949- ) ;
957+ // Move refresh_key into the guard to avoid an
958+ // extra clone of potentially large search_paths.
959+ let mut safety_guard =
960+ RefreshSafetyGuard :: new ( & context . refresh_coordinator , refresh_key ) ;
950961
951962 let refresh_result = panic:: catch_unwind ( AssertUnwindSafe ( || {
952963 execute_refresh (
@@ -961,7 +972,7 @@ pub fn handle_refresh(context: Arc<Context>, id: u32, params: Value) {
961972 let refresh_result = execution. result . clone ( ) ;
962973 let mut completion_guard = RefreshCompletionGuard :: begin (
963974 & context. refresh_coordinator ,
964- & refresh_key ,
975+ & safety_guard . key ,
965976 ) ;
966977 safety_guard. disarm ( ) ;
967978 finish_refresh_replies ( & mut completion_guard, & refresh_result) ;
@@ -974,7 +985,7 @@ pub fn handle_refresh(context: Arc<Context>, id: u32, params: Value) {
974985 ) ;
975986 let mut completion_guard = RefreshCompletionGuard :: begin (
976987 & context. refresh_coordinator ,
977- & refresh_key ,
988+ & safety_guard . key ,
978989 ) ;
979990 safety_guard. disarm ( ) ;
980991 finish_refresh_errors (
0 commit comments