Improve warning message when protocol downgrade is used

also don't log error when we're defuncting for unsupported protocol

PYTHON-157
This commit is contained in:
Adam Holmberg
2016-04-22 09:56:37 -05:00
parent da994dcd3a
commit f72b207c3c
2 changed files with 5 additions and 3 deletions

View File

@@ -868,7 +868,9 @@ class Cluster(object):
new_version = previous_version - 1
if new_version < self.protocol_version:
if new_version >= MIN_SUPPORTED_VERSION:
log.warning("Downgrading core protocol version from %d to %d for %s", self.protocol_version, new_version, host_addr)
log.warning("Downgrading core protocol version from %d to %d for %s. "
"To avoid this, it is best practice to explicitly set Cluster(protocol_version) to the version supported by your cluster. "
"http://datastax.github.io/python-driver/api/cassandra/cluster.html#cassandra.cluster.Cluster.protocol_version", self.protocol_version, new_version, host_addr)
self.protocol_version = new_version
else:
raise DriverException("Cannot downgrade protocol version (%d) below minimum supported version: %d" % (new_version, MIN_SUPPORTED_VERSION))

View File

@@ -601,8 +601,8 @@ class Connection(object):
if isinstance(response, ProtocolException):
if 'unsupported protocol version' in response.message:
self.is_unsupported_proto_version = True
log.error("Closing connection %s due to protocol error: %s", self, response.summary_msg())
else:
log.error("Closing connection %s due to protocol error: %s", self, response.summary_msg())
self.defunct(response)
if callback is not None:
callback(response)