Don't reconnect to IGNORED hosts when marked down

This commit is contained in:
Tyler Hobbs
2014-07-09 18:29:49 -05:00
parent 1ae4b82fac
commit 25a7acf5f9
3 changed files with 14 additions and 2 deletions

View File

@@ -45,6 +45,9 @@ Bug Fixes
contact points (PYTHON-90)
* Make Murmur3 hash match Cassandra's hash for all values (PYTHON-89,
github #147)
* Don't attempt to reconnect to hosts that should be ignored (according
to the load balancing policy) when a notification is received that the
host is down.
2.0.2
=====

View File

@@ -772,6 +772,9 @@ class Cluster(object):
return futures
def _start_reconnector(self, host, is_host_addition):
if self.load_balancing_policy.distance(host) == HostDistance.IGNORED:
return
schedule = self.reconnection_policy.new_schedule()
# in order to not hold references to this Cluster open and prevent

View File

@@ -13,6 +13,7 @@
# limitations under the License.
import struct
import time
from cassandra import ConsistencyLevel, Unavailable
from cassandra.cluster import Cluster, NoHostAvailable
from cassandra.concurrent import execute_concurrent_with_args
@@ -469,9 +470,14 @@ class LoadBalancingPolicyTests(unittest.TestCase):
self.coordinator_stats.assert_query_count_equals(self, 2, 12)
self.coordinator_stats.assert_query_count_equals(self, 3, 0)
# white list policy should not allow reconnecting to ignored hosts
force_stop(3)
wait_for_down(cluster, 3)
self.assertFalse(cluster.metadata._hosts[IP_FORMAT % 3].is_currently_reconnecting())
self.coordinator_stats.reset_counts()
decommission(2)
wait_for_down(cluster, 2, wait=True)
force_stop(2)
time.sleep(10)
try:
self._query(session, keyspace)