diff --git a/src/meta/src/barrier/schedule.rs b/src/meta/src/barrier/schedule.rs index bb989d13de7f9..b0b6569bc4592 100644 --- a/src/meta/src/barrier/schedule.rs +++ b/src/meta/src/barrier/schedule.rs @@ -369,12 +369,11 @@ impl ScheduledBarriers { loop { let mut rx = self.inner.changed_tx.subscribe(); let mut queue = self.inner.queue.write().await; - if queue.queue.is_empty() { - rx.changed().await.unwrap(); + if let Some(scheduled) = queue.queue.pop_front() { + break scheduled } else { - let scheduled = queue.queue.pop_front().expect("non-empty"); - - break scheduled; + drop(queue); + rx.changed().await.unwrap(); } } } => {