Skip to content

Commit 25a7acf

Browse files
committed
Don't reconnect to IGNORED hosts when marked down
1 parent 1ae4b82 commit 25a7acf

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Bug Fixes
4545
contact points (PYTHON-90)
4646
* Make Murmur3 hash match Cassandra's hash for all values (PYTHON-89,
4747
github #147)
48+
* Don't attempt to reconnect to hosts that should be ignored (according
49+
to the load balancing policy) when a notification is received that the
50+
host is down.
4851

4952
2.0.2
5053
=====

cassandra/cluster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ def on_up(self, host):
772772
return futures
773773

774774
def _start_reconnector(self, host, is_host_addition):
775+
if self.load_balancing_policy.distance(host) == HostDistance.IGNORED:
776+
return
777+
775778
schedule = self.reconnection_policy.new_schedule()
776779

777780
# in order to not hold references to this Cluster open and prevent

tests/integration/long/test_loadbalancingpolicies.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import struct
16+
import time
1617
from cassandra import ConsistencyLevel, Unavailable
1718
from cassandra.cluster import Cluster, NoHostAvailable
1819
from cassandra.concurrent import execute_concurrent_with_args
@@ -469,9 +470,14 @@ def test_white_list(self):
469470
self.coordinator_stats.assert_query_count_equals(self, 2, 12)
470471
self.coordinator_stats.assert_query_count_equals(self, 3, 0)
471472

473+
# white list policy should not allow reconnecting to ignored hosts
474+
force_stop(3)
475+
wait_for_down(cluster, 3)
476+
self.assertFalse(cluster.metadata._hosts[IP_FORMAT % 3].is_currently_reconnecting())
477+
472478
self.coordinator_stats.reset_counts()
473-
decommission(2)
474-
wait_for_down(cluster, 2, wait=True)
479+
force_stop(2)
480+
time.sleep(10)
475481

476482
try:
477483
self._query(session, keyspace)

0 commit comments

Comments
 (0)