Skip to content

Commit 94fd862

Browse files
committed
fix deadlock when polling multiple times from Kafka
1 parent c3eeb81 commit 94fd862

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/kgo/consumer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ func (c *consumer) waitAndAddPoller() {
239239
}
240240
c.pollWaitMu.Lock()
241241
defer c.pollWaitMu.Unlock()
242-
for c.pollWaitState>>32 != 0 {
243-
c.pollWaitC.Wait()
242+
if c.pollWaitState&math.MaxUint32 == 0 {
243+
for c.pollWaitState>>32 != 0 {
244+
c.pollWaitC.Wait()
245+
}
244246
}
245247
// Rebalance always takes priority, but if there are no active
246248
// rebalances, our poll blocks rebalances.

0 commit comments

Comments
 (0)