Skip to content

Commit 7042125

Browse files
committed
Remove protocol versions >5 from MAX_SUPPORTED
Without removing associated code yet, this patch just ensure we begin negotiating protocol version 5, then fallback to 4, reducing the amount of protocol errors that the Scylla server sends when it sees the unsupported versions. Refs: #244 Signed-off-by: Yaniv Kaul <[email protected]>
1 parent 3f7bcbb commit 7042125

18 files changed

+20
-918
lines changed

cassandra/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class ProtocolVersion(object):
180180
DSE private protocol v2, supported in DSE 6.0+
181181
"""
182182

183-
SUPPORTED_VERSIONS = (DSE_V2, DSE_V1, V6, V5, V4, V3, V2, V1)
183+
SUPPORTED_VERSIONS = (V5, V4, V3, V2, V1)
184184
"""
185185
A tuple of all supported protocol versions
186186
"""
@@ -237,10 +237,6 @@ def uses_keyspace_flag(cls, version):
237237
def has_continuous_paging_support(cls, version):
238238
return version >= cls.DSE_V1
239239

240-
@classmethod
241-
def has_continuous_paging_next_pages(cls, version):
242-
return version >= cls.DSE_V2
243-
244240
@classmethod
245241
def has_checksumming_support(cls, version):
246242
return cls.V5 <= version < cls.DSE_V1

cassandra/cluster.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from cassandra.connection import (ConnectionException, ConnectionShutdown,
5252
ConnectionHeartbeat, ProtocolVersionUnsupported,
5353
EndPoint, DefaultEndPoint, DefaultEndPointFactory,
54-
ContinuousPagingState, SniEndPointFactory, ConnectionBusy)
54+
SniEndPointFactory, ConnectionBusy)
5555
from cassandra.cqltypes import UserType
5656
import cassandra.cqltypes as types
5757
from cassandra.encoder import Encoder
@@ -672,7 +672,7 @@ class Cluster(object):
672672
server will be automatically used.
673673
"""
674674

675-
protocol_version = ProtocolVersion.DSE_V2
675+
protocol_version = ProtocolVersion.V5
676676
"""
677677
The maximum version of the native protocol to use.
678678
@@ -2749,7 +2749,6 @@ def __init__(self, cluster, hosts, keyspace=None):
27492749
raise NoHostAvailable(msg, [h.address for h in hosts])
27502750

27512751
self.session_id = uuid.uuid4()
2752-
self._graph_paging_available = self._check_graph_paging_available()
27532752

27542753
if self.cluster.column_encryption_policy is not None:
27552754
try:
@@ -2946,26 +2945,10 @@ def execute_graph_async(self, query, parameters=None, trace=False, execution_pro
29462945
def _maybe_set_graph_paging(self, execution_profile):
29472946
graph_paging = execution_profile.continuous_paging_options
29482947
if execution_profile.continuous_paging_options is _NOT_SET:
2949-
graph_paging = ContinuousPagingOptions() if self._graph_paging_available else None
2948+
graph_paging = None
29502949

29512950
execution_profile.continuous_paging_options = graph_paging
29522951

2953-
def _check_graph_paging_available(self):
2954-
"""Verify if we can enable graph paging. This executed only once when the session is created."""
2955-
2956-
if not ProtocolVersion.has_continuous_paging_next_pages(self._protocol_version):
2957-
return False
2958-
2959-
for host in self.cluster.metadata.all_hosts():
2960-
if host.dse_version is None:
2961-
return False
2962-
2963-
version = Version(host.dse_version)
2964-
if version < _GRAPH_PAGING_MIN_DSE_VERSION:
2965-
return False
2966-
2967-
return True
2968-
29692952
def _resolve_execution_profile_options(self, execution_profile):
29702953
"""
29712954
Determine the GraphSON protocol and row factory for a graph query. This is useful
@@ -3112,13 +3095,7 @@ def _create_response_future(self, query, parameters, trace, custom_payload,
31123095
else:
31133096
timestamp = None
31143097

3115-
supports_continuous_paging_state = (
3116-
ProtocolVersion.has_continuous_paging_next_pages(self._protocol_version)
3117-
)
3118-
if continuous_paging_options and supports_continuous_paging_state:
3119-
continuous_paging_state = ContinuousPagingState(continuous_paging_options.max_queue_size)
3120-
else:
3121-
continuous_paging_state = None
3098+
continuous_paging_state = None
31223099

31233100
if isinstance(query, SimpleStatement):
31243101
query_string = query.query_string

cassandra/connection.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -445,32 +445,6 @@ class CrcMismatchException(ConnectionException):
445445
pass
446446

447447

448-
class ContinuousPagingState(object):
449-
"""
450-
A class for specifying continuous paging state, only supported starting with DSE_V2.
451-
"""
452-
453-
num_pages_requested = None
454-
"""
455-
How many pages we have already requested
456-
"""
457-
458-
num_pages_received = None
459-
"""
460-
How many pages we have already received
461-
"""
462-
463-
max_queue_size = None
464-
"""
465-
The max queue size chosen by the user via the options
466-
"""
467-
468-
def __init__(self, max_queue_size):
469-
self.num_pages_requested = max_queue_size # the initial query requests max_queue_size
470-
self.num_pages_received = 0
471-
self.max_queue_size = max_queue_size
472-
473-
474448
class ContinuousPagingSession(object):
475449
def __init__(self, stream_id, decoder, row_factory, connection, state):
476450
self.stream_id = stream_id

cassandra/protocol.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ def _write_query_params(self, f, protocol_version):
631631
def _write_paging_options(self, f, paging_options, protocol_version):
632632
write_int(f, paging_options.max_pages)
633633
write_int(f, paging_options.max_pages_per_second)
634-
if ProtocolVersion.has_continuous_paging_next_pages(protocol_version):
635-
write_int(f, paging_options.max_queue_size)
636634

637635

638636
class QueryMessage(_QueryMessage):
@@ -1092,12 +1090,10 @@ def send_body(self, f, protocol_version):
10921090
if self.op_type == ReviseRequestMessage.RevisionType.PAGING_BACKPRESSURE:
10931091
if self.next_pages <= 0:
10941092
raise UnsupportedOperation("Continuous paging backpressure requires next_pages > 0")
1095-
elif not ProtocolVersion.has_continuous_paging_next_pages(protocol_version):
1093+
else:
10961094
raise UnsupportedOperation(
10971095
"Continuous paging backpressure may only be used with protocol version "
10981096
"ProtocolVersion.DSE_V2 or higher. Consider setting Cluster.protocol_version to ProtocolVersion.DSE_V2.")
1099-
else:
1100-
write_int(f, self.next_pages)
11011097

11021098

11031099
class _ProtocolHandler(object):

tests/integration/__init__.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,9 @@ def _get_dse_version_from_cass(cass_version):
228228

229229
def get_default_protocol():
230230
if CASSANDRA_VERSION >= Version('4.0-a'):
231-
if DSE_VERSION:
232-
return ProtocolVersion.DSE_V2
233-
else:
234-
return ProtocolVersion.V5
231+
return ProtocolVersion.V5
235232
if CASSANDRA_VERSION >= Version('3.10'):
236-
if DSE_VERSION:
237-
return ProtocolVersion.DSE_V1
238-
else:
239-
return 4
233+
return 4
240234
if CASSANDRA_VERSION >= Version('2.2'):
241235
return 4
242236
elif CASSANDRA_VERSION >= Version('2.1'):
@@ -274,15 +268,9 @@ def get_supported_protocol_versions():
274268
if not DSE_VERSION:
275269
return (3, 4, 5, 6)
276270
if CASSANDRA_VERSION >= Version('4.0-a'):
277-
if DSE_VERSION:
278-
return (3, 4, ProtocolVersion.DSE_V1, ProtocolVersion.DSE_V2)
279-
else:
280-
return (3, 4, 5)
271+
return (3, 4, 5)
281272
elif CASSANDRA_VERSION >= Version('3.10'):
282-
if DSE_VERSION:
283-
return (3, 4, ProtocolVersion.DSE_V1)
284-
else:
285-
return (3, 4)
273+
return (3, 4)
286274
elif CASSANDRA_VERSION >= Version('3.0'):
287275
return (3, 4)
288276
elif CASSANDRA_VERSION >= Version('2.2'):
@@ -322,10 +310,7 @@ def get_unsupported_upper_protocol():
322310
else:
323311
return ProtocolVersion.DSE_V1
324312
if CASSANDRA_VERSION >= Version('3.10'):
325-
if DSE_VERSION:
326-
return ProtocolVersion.DSE_V2
327-
else:
328-
return 5
313+
return 5
329314
if CASSANDRA_VERSION >= Version('2.2'):
330315
return 5
331316
elif CASSANDRA_VERSION >= Version('2.1'):
@@ -357,7 +342,6 @@ def _id_and_mark(f):
357342
lessthenprotocolv4 = unittest.skipUnless(PROTOCOL_VERSION < 4, 'Protocol versions 4 or greater not supported')
358343
lessthanprotocolv3 = unittest.skipUnless(PROTOCOL_VERSION < 3, 'Protocol versions 3 or greater not supported')
359344
greaterthanprotocolv3 = unittest.skipUnless(PROTOCOL_VERSION >= 4, 'Protocol versions less than 4 are not supported')
360-
protocolv6 = unittest.skipUnless(6 in get_supported_protocol_versions(), 'Protocol versions less than 6 are not supported')
361345

362346
greaterthancass20 = unittest.skipUnless(CASSANDRA_VERSION >= Version('2.1'), 'Cassandra version 2.1 or greater required')
363347
greaterthancass21 = unittest.skipUnless(CASSANDRA_VERSION >= Version('2.2'), 'Cassandra version 2.2 or greater required')
@@ -372,9 +356,6 @@ def _id_and_mark(f):
372356
lessthancass40 = unittest.skipUnless(CASSANDRA_VERSION < Version('4.0'), 'Cassandra version less than 4.0 required')
373357
lessthancass30 = unittest.skipUnless(CASSANDRA_VERSION < Version('3.0'), 'Cassandra version less then 3.0 required')
374358

375-
greaterthanorequaldse68 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('6.8'), "DSE 6.8 or greater required for this test")
376-
greaterthanorequaldse67 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('6.7'), "DSE 6.7 or greater required for this test")
377-
greaterthanorequaldse60 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('6.0'), "DSE 6.0 or greater required for this test")
378359
greaterthanorequaldse51 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('5.1'), "DSE 5.1 or greater required for this test")
379360
greaterthanorequaldse50 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('5.0'), "DSE 5.0 or greater required for this test")
380361
lessthandse51 = unittest.skipUnless(DSE_VERSION and DSE_VERSION < Version('5.1'), "DSE version less than 5.1 required")

0 commit comments

Comments
 (0)