1 parent 84589c1 commit 5a31d17Copy full SHA for 5a31d17
1 file changed
crates/arroyo-operator/src/context.rs
@@ -138,9 +138,19 @@ impl BatchSender {
138
}
139
140
} else {
141
- // not enough room in the queue, wait to be notified that the receiver has
142
- // consumed
143
- self.notify.notified().await;
+ // first register the notify listener
+ let notified = self.notify.notified();
+
144
+ // then recheck -- there may now be space since we checked
145
+ let cur = self.queued_messages.load(Ordering::Acquire);
146
+ if cur as usize + count as usize <= self.size as usize {
147
+ // space is now available, retry immediately
148
+ continue;
149
+ }
150
151
+ // if not, we're now guaranteed to receive the notification if space is made
152
+ // available
153
+ notified.await;
154
155
156
0 commit comments