Skip to content

Commit 11a07bc

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 11a07bc

File tree

5 files changed

+5
-97
lines changed

5 files changed

+5
-97
lines changed

cassandra/__init__.py

Lines changed: 1 addition & 1 deletion
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
"""

cassandra/cluster.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tests/integration/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ def _id_and_mark(f):
357357
lessthenprotocolv4 = unittest.skipUnless(PROTOCOL_VERSION < 4, 'Protocol versions 4 or greater not supported')
358358
lessthanprotocolv3 = unittest.skipUnless(PROTOCOL_VERSION < 3, 'Protocol versions 3 or greater not supported')
359359
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')
361360

362361
greaterthancass20 = unittest.skipUnless(CASSANDRA_VERSION >= Version('2.1'), 'Cassandra version 2.1 or greater required')
363362
greaterthancass21 = unittest.skipUnless(CASSANDRA_VERSION >= Version('2.2'), 'Cassandra version 2.2 or greater required')
@@ -372,9 +371,6 @@ def _id_and_mark(f):
372371
lessthancass40 = unittest.skipUnless(CASSANDRA_VERSION < Version('4.0'), 'Cassandra version less than 4.0 required')
373372
lessthancass30 = unittest.skipUnless(CASSANDRA_VERSION < Version('3.0'), 'Cassandra version less then 3.0 required')
374373

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")
378374
greaterthanorequaldse51 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('5.1'), "DSE 5.1 or greater required for this test")
379375
greaterthanorequaldse50 = unittest.skipUnless(DSE_VERSION and DSE_VERSION >= Version('5.0'), "DSE 5.0 or greater required for this test")
380376
lessthandse51 = unittest.skipUnless(DSE_VERSION and DSE_VERSION < Version('5.1'), "DSE version less than 5.1 required")

tests/integration/advanced/graph/test_graph_cont_paging.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,6 @@
1414

1515
from cassandra.cluster import ContinuousPagingOptions
1616

17-
from tests.integration import greaterthanorequaldse68
1817
from tests.integration.advanced.graph import GraphUnitTestCase, CoreGraphSchema, GraphTestConfiguration
1918

2019

21-
@greaterthanorequaldse68
22-
@GraphTestConfiguration.generate_tests(schema=CoreGraphSchema)
23-
class GraphPagingTest(GraphUnitTestCase):
24-
25-
def _setup_data(self, schema, graphson):
26-
self.execute_graph("schema.vertexLabel('person').ifNotExists().partitionBy('name', Text).property('age', Int).create();", graphson)
27-
for i in range(100):
28-
self.execute_graph("g.addV('person').property('name', 'batman-{}')".format(i), graphson)
29-
30-
def _test_cont_paging_is_enabled_by_default(self, schema, graphson):
31-
"""
32-
Test that graph paging is automatically enabled with a >=6.8 cluster.
33-
34-
@jira_ticket PYTHON-1045
35-
@expected_result the response future has a continuous_paging_session since graph paging is enabled
36-
37-
@test_category dse graph
38-
"""
39-
ep = self.get_execution_profile(graphson)
40-
self._setup_data(schema, graphson)
41-
rf = self.session.execute_graph_async("g.V()", execution_profile=ep)
42-
results = list(rf.result())
43-
self.assertIsNotNone(rf._continuous_paging_session)
44-
self.assertEqual(len(results), 100)
45-
46-
def _test_cont_paging_can_be_disabled(self, schema, graphson):
47-
"""
48-
Test that graph paging can be disabled.
49-
50-
@jira_ticket PYTHON-1045
51-
@expected_result the response future doesn't have a continuous_paging_session since graph paging is disabled
52-
53-
@test_category dse graph
54-
"""
55-
ep = self.get_execution_profile(graphson)
56-
new_ep = self.session.execution_profile_clone_update(ep, continuous_paging_options=None)
57-
self._setup_data(schema, graphson)
58-
rf = self.session.execute_graph_async("g.V()", execution_profile=new_ep)
59-
results = list(rf.result())
60-
self.assertIsNone(rf._continuous_paging_session)
61-
self.assertEqual(len(results), 100)
62-
63-
def _test_cont_paging_with_custom_options(self, schema, graphson):
64-
"""
65-
Test that we can specify custom paging options.
66-
67-
@jira_ticket PYTHON-1045
68-
@expected_result we get only the desired number of results
69-
70-
@test_category dse graph
71-
"""
72-
ep = self.get_execution_profile(graphson)
73-
new_ep = self.session.execution_profile_clone_update(
74-
ep, continuous_paging_options=ContinuousPagingOptions(max_pages=1))
75-
self._setup_data(schema, graphson)
76-
self.session.default_fetch_size = 10
77-
results = list(self.session.execute_graph("g.V()", execution_profile=new_ep))
78-
self.assertEqual(len(results), 10)

tests/integration/standard/test_cluster.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,7 @@ def test_protocol_negotiation(self):
255255
updated_protocol_version = session._protocol_version
256256
updated_cluster_version = cluster.protocol_version
257257
# Make sure the correct protocol was selected by default
258-
if DSE_VERSION and DSE_VERSION >= Version("6.0"):
259-
self.assertEqual(updated_protocol_version, cassandra.ProtocolVersion.DSE_V2)
260-
self.assertEqual(updated_cluster_version, cassandra.ProtocolVersion.DSE_V2)
261-
elif DSE_VERSION and DSE_VERSION >= Version("5.1"):
262-
self.assertEqual(updated_protocol_version, cassandra.ProtocolVersion.DSE_V1)
263-
self.assertEqual(updated_cluster_version, cassandra.ProtocolVersion.DSE_V1)
264-
elif CASSANDRA_VERSION >= Version('4.0-beta5'):
258+
if CASSANDRA_VERSION >= Version('4.0-beta5'):
265259
self.assertEqual(updated_protocol_version, cassandra.ProtocolVersion.V5)
266260
self.assertEqual(updated_cluster_version, cassandra.ProtocolVersion.V5)
267261
elif CASSANDRA_VERSION >= Version('4.0-a'):

0 commit comments

Comments
 (0)