File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -577,6 +577,13 @@ impl ModuleHost {
577577 . with_label_values ( & self . info . database_identity )
578578 . observe ( queue_length as f64 ) ;
579579 }
580+ // Ensure that we always decrement the gauge.
581+ let timer_guard = scopeguard:: guard ( ( ) , move |_| {
582+ // Decrement the queue length gauge when we're done.
583+ // This is done in a defer so that it happens even if the reducer call panics.
584+ queue_length_gauge. dec ( ) ;
585+ queue_timer. stop_and_record ( ) ;
586+ } ) ;
580587
581588 // Operations on module instances (e.g. calling reducers) is blocking,
582589 // partially because the computation can potentialyl take a long time
@@ -593,8 +600,7 @@ impl ModuleHost {
593600 } ) ;
594601 self . job_tx
595602 . run ( move |inst| {
596- queue_timer. stop_and_record ( ) ;
597- queue_length_gauge. dec ( ) ;
603+ drop ( timer_guard) ;
598604 f ( inst)
599605 } )
600606 . await
You can’t perform that action at this time.
0 commit comments