Skip to content

Commit 59ebff4

Browse files
committed
(Improvement) Remove CQL binary protocol v3
No one needs it anymore. Any reasonable version of Cassandra and ScyllaDB support CQL binary protocol v4 (or higher). This also assume that we test against Cassandra 2.2 or above, so removed some <= 2.1 items. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
1 parent e2894fb commit 59ebff4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+455
-1147
lines changed

CONTRIBUTING.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ The test will start the appropriate Scylla clusters when necessary but if you d
8989
Specify a Protocol Version for Tests
9090
------------------------------------
9191
The protocol version defaults to:
92-
- 4 for Scylla >= 3.0 and Scylla Enterprise > 2019.
93-
- 3 for older versions of Scylla
94-
- 5 for Cassandra >= 4.0, 4 for Cassandra >= 2.2, 3 for Cassandra >= 2.1, 2 for Cassandra >= 2.0
92+
- 4 for Scylla.
93+
- 5 for Cassandra >= 4.0, 4 for Cassandra >= 2.2
9594
You can overwrite it with the ``PROTOCOL_VERSION`` environment variable::
9695

97-
PROTOCOL_VERSION=3 SCYLLA_VERSION="release:5.1" uv run pytest tests/integration/standard tests/integration/cqlengine/
96+
PROTOCOL_VERSION=4 SCYLLA_VERSION="release:5.1" uv run pytest tests/integration/standard tests/integration/cqlengine/
9897

9998
Seeing Test Logs in Real Time
10099
-----------------------------

cassandra/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ class ProtocolVersion(object):
136136
Defines native protocol versions supported by this driver.
137137
"""
138138

139-
V3 = 3
140-
"""
141-
v3, supported in Cassandra 2.1-->3.x+;
142-
added support for protocol-level client-side timestamps (see :attr:`.Session.use_client_timestamp`),
143-
serial consistency levels for :class:`~.BatchStatement`, and an improved connection pool.
144-
"""
145-
146139
V4 = 4
147140
"""
148141
v4, supported in Cassandra 2.2-->3.x+;
@@ -170,9 +163,9 @@ class ProtocolVersion(object):
170163
DSE private protocol v2, supported in DSE 6.0+
171164
"""
172165

173-
SUPPORTED_VERSIONS = (V5, V4, V3)
166+
SUPPORTED_VERSIONS = (V5, V4)
174167
"""
175-
A tuple of all supported protocol versions for ScyllaDB, including future v5 version.
168+
A tuple of all supported protocol versions for ScyllaDB.
176169
"""
177170

178171
BETA_VERSIONS = (V6,)

cassandra/cluster.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,9 @@ def application_info(self) -> Optional[ApplicationInfoBase]:
717717
@property
718718
def auth_provider(self):
719719
"""
720-
When :attr:`~.Cluster.protocol_version` is 2 or higher, this should
721-
be an instance of a subclass of :class:`~cassandra.auth.AuthProvider`,
720+
This should be an instance of a subclass of :class:`~cassandra.auth.AuthProvider`,
722721
such as :class:`~.PlainTextAuthProvider`.
723722
724-
725723
When not using authentication, this should be left as :const:`None`.
726724
"""
727725
return self._auth_provider
@@ -735,12 +733,7 @@ def auth_provider(self, value):
735733
try:
736734
self._auth_provider_callable = value.new_authenticator
737735
except AttributeError:
738-
if self.protocol_version > 1:
739-
raise TypeError("auth_provider must implement the cassandra.auth.AuthProvider "
740-
"interface when protocol_version >= 2")
741-
elif not callable(value):
742-
raise TypeError("auth_provider must be callable when protocol_version == 1")
743-
self._auth_provider_callable = value
736+
raise TypeError("auth_provider must implement the cassandra.auth.AuthProvider interface")
744737

745738
self._auth_provider = value
746739

@@ -1557,7 +1550,7 @@ def register_user_type(self, keyspace, user_type, klass):
15571550
15581551
Example::
15591552
1560-
cluster = Cluster(protocol_version=3)
1553+
cluster = Cluster(protocol_version=4)
15611554
session = cluster.connect()
15621555
session.set_keyspace('mykeyspace')
15631556
session.execute("CREATE TYPE address (street text, zipcode int)")
@@ -1582,11 +1575,6 @@ def __init__(self, street, zipcode):
15821575
print(row.id, row.location.street, row.location.zipcode)
15831576
15841577
"""
1585-
if self.protocol_version < 3:
1586-
log.warning("User Type serialization is only supported in native protocol version 3+ (%d in use). "
1587-
"CQL encoding for simple statements will still work, but named tuples will "
1588-
"be returned when reading type %s.%s.", self.protocol_version, keyspace, user_type)
1589-
15901578
self._user_types[keyspace][user_type] = klass
15911579
for session in tuple(self.sessions):
15921580
session.user_type_registered(keyspace, user_type, klass)
@@ -2445,8 +2433,6 @@ def default_serial_consistency_level(self):
24452433
The default :class:`~ConsistencyLevel` for serial phase of conditional updates executed through
24462434
this session. This default may be overridden by setting the
24472435
:attr:`~.Statement.serial_consistency_level` on individual statements.
2448-
2449-
Only valid for ``protocol_version >= 2``.
24502436
"""
24512437
return self._default_serial_consistency_level
24522438

@@ -2957,11 +2943,6 @@ def _create_response_future(self, query, parameters, trace, custom_payload,
29572943
continuous_paging_options=continuous_paging_options,
29582944
result_metadata_id=prepared_statement.result_metadata_id)
29592945
elif isinstance(query, BatchStatement):
2960-
if self._protocol_version < 2:
2961-
raise UnsupportedOperation(
2962-
"BatchStatement execution is only supported with protocol version "
2963-
"2 or higher (supported in Cassandra 2.0 and higher). Consider "
2964-
"setting Cluster.protocol_version to 2 to support this operation.")
29652946
statement_keyspace = query.keyspace if ProtocolVersion.uses_keyspace_flag(self._protocol_version) else None
29662947
message = BatchMessage(
29672948
query.batch_type, query._statements_and_parameters, cl,
@@ -3100,7 +3081,7 @@ def prepare(self, query, custom_payload=None, keyspace=None):
31003081
prepared_keyspace = keyspace if keyspace else None
31013082
prepared_statement = PreparedStatement.from_message(
31023083
response.query_id, response.bind_metadata, response.pk_indexes, self.cluster.metadata, query, prepared_keyspace,
3103-
self._protocol_version, response.column_metadata, response.result_metadata_id, response.is_lwt, self.cluster.column_encryption_policy)
3084+
response.column_metadata, response.result_metadata_id, response.is_lwt, self.cluster.column_encryption_policy)
31043085
prepared_statement.custom_payload = future.custom_payload
31053086

31063087
self.cluster.add_prepared(response.query_id, prepared_statement)
@@ -4640,10 +4621,9 @@ def _set_result(self, host, connection, pool, response):
46404621
self._custom_payload = getattr(response, 'custom_payload', None)
46414622

46424623
if self._custom_payload and self.session.cluster.control_connection._tablets_routing_v1 and 'tablets-routing-v1' in self._custom_payload:
4643-
protocol = self.session.cluster.protocol_version
46444624
info = self._custom_payload.get('tablets-routing-v1')
46454625
ctype = types.lookup_casstype('TupleType(LongType, LongType, ListType(TupleType(UUIDType, Int32Type)))')
4646-
tablet_routing_info = ctype.from_binary(info, protocol)
4626+
tablet_routing_info = ctype.from_binary(info)
46474627
first_token = tablet_routing_info[0]
46484628
last_token = tablet_routing_info[1]
46494629
tablet_replicas = tablet_routing_info[2]

cassandra/connection.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from cassandra import ConsistencyLevel, AuthenticationFailed, OperationTimedOut, ProtocolVersion
4242
from cassandra.marshal import int32_pack
4343
from cassandra.protocol import (ReadyMessage, AuthenticateMessage, OptionsMessage,
44-
StartupMessage, ErrorMessage, CredentialsMessage,
44+
StartupMessage, ErrorMessage,
4545
QueryMessage, ResultMessage, ProtocolHandler,
4646
InvalidRequestException, SupportedMessage,
4747
AuthResponseMessage, AuthChallengeMessage,
@@ -1477,18 +1477,12 @@ def _handle_startup_response(self, startup_response, did_authenticate=False):
14771477
if ProtocolVersion.has_checksumming_support(self.protocol_version):
14781478
self._enable_checksumming()
14791479

1480-
if isinstance(self.authenticator, dict):
1481-
log.debug("Sending credentials-based auth response on %s", self)
1482-
cm = CredentialsMessage(creds=self.authenticator)
1483-
callback = partial(self._handle_startup_response, did_authenticate=True)
1484-
self.send_msg(cm, self.get_request_id(), cb=callback)
1485-
else:
1486-
log.debug("Sending SASL-based auth response on %s", self)
1487-
self.authenticator.server_authenticator_class = startup_response.authenticator
1488-
initial_response = self.authenticator.initial_response()
1489-
initial_response = "" if initial_response is None else initial_response
1490-
self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(),
1491-
self._handle_auth_response)
1480+
log.debug("Sending SASL-based auth response on %s", self)
1481+
self.authenticator.server_authenticator_class = startup_response.authenticator
1482+
initial_response = self.authenticator.initial_response()
1483+
initial_response = "" if initial_response is None else initial_response
1484+
self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(),
1485+
self._handle_auth_response)
14921486
elif isinstance(startup_response, ErrorMessage):
14931487
log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
14941488
id(self), self.endpoint, startup_response.summary_msg())

cassandra/cqlengine/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ def _transform_column(col_name, col_obj):
948948
key_cols = [c for c in partition_keys.values()]
949949
partition_key_index = dict((col.db_field_name, col._partition_key_index) for col in key_cols)
950950
key_cql_types = [c.cql_type for c in key_cols]
951-
key_serializer = staticmethod(lambda parts, proto_version: [t.to_binary(p, proto_version) for t, p in zip(key_cql_types, parts)])
951+
key_serializer = staticmethod(lambda parts, proto_version: [t.to_binary(p) for t, p in zip(key_cql_types, parts)])
952952
else:
953953
partition_key_index = {}
954954
key_serializer = staticmethod(lambda parts, proto_version: None)

0 commit comments

Comments
 (0)