From eb6d8dc608e509085dd7abc239666e5ab4a944e8 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Thu, 6 Feb 2025 08:13:49 -0800 Subject: [PATCH] Release coordinator lock before calling maybe_leave_group --- kafka/coordinator/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kafka/coordinator/base.py b/kafka/coordinator/base.py index e71984108..f2eaefc6c 100644 --- a/kafka/coordinator/base.py +++ b/kafka/coordinator/base.py @@ -990,6 +990,11 @@ def _run_once(self): # foreground thread has stalled in between calls to # poll(), so we explicitly leave the group. log.warning('Heartbeat poll expired, leaving group') + ### XXX + # maybe_leave_group acquires client + coordinator lock; + # if we hold coordinator lock before calling, we risk deadlock + # release() is safe here because this is the last code in the current context + self.coordinator._lock.release() self.coordinator.maybe_leave_group() elif not self.coordinator.heartbeat.should_heartbeat():