Skip to content

Commit 7b287a8

Browse files
committed
Fix wait_for_schema_agreement deadlock
Fixes #168 Fix works by extracting part of on_down that marks host as down out of the executor - so it does not need to wait for free thread. When host is marked as down, wait_for_schema_agreement can finish, which in turn enables rest of on_down (the part that still runs on executor) to be executed.
1 parent 7c9df85 commit 7b287a8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

cassandra/cluster.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,17 @@ def _start_reconnector(self, host, is_host_addition):
20032003
reconnector.start()
20042004

20052005
@run_in_executor
2006+
def on_down_potentially_blocking(self, host, is_host_addition):
2007+
self.profile_manager.on_down(host)
2008+
self.control_connection.on_down(host)
2009+
for session in tuple(self.sessions):
2010+
session.on_down(host)
2011+
2012+
for listener in self.listeners:
2013+
listener.on_down(host)
2014+
2015+
self._start_reconnector(host, is_host_addition)
2016+
20062017
def on_down(self, host, is_host_addition, expect_host_to_be_down=False):
20072018
"""
20082019
Intended for internal use only.
@@ -2028,18 +2039,9 @@ def on_down(self, host, is_host_addition, expect_host_to_be_down=False):
20282039
host.set_down()
20292040
if (not was_up and not expect_host_to_be_down) or host.is_currently_reconnecting():
20302041
return
2031-
20322042
log.warning("Host %s has been marked down", host)
20332043

2034-
self.profile_manager.on_down(host)
2035-
self.control_connection.on_down(host)
2036-
for session in tuple(self.sessions):
2037-
session.on_down(host)
2038-
2039-
for listener in self.listeners:
2040-
listener.on_down(host)
2041-
2042-
self._start_reconnector(host, is_host_addition)
2044+
self.on_down_potentially_blocking(host, is_host_addition)
20432045

20442046
def on_add(self, host, refresh_nodes=True):
20452047
if self.is_shutdown:

0 commit comments

Comments
 (0)