Skip to content

Commit ade35d8

Browse files
committed
fix: gate skip_meta and result_metadata_id on connection features at send-time
Using result_metadata_id != None as a proxy for whether SCYLLA_USE_METADATA_ID was negotiated is unreliable in mixed-version clusters: a statement prepared against a Scylla node (which sets result_metadata_id) could then be executed against a node that doesn't support the extension, shifting the EXECUTE wire layout and causing protocol errors. Move the skip_meta and result_metadata_id decisions into _query(), where the borrowed connection is known. Both are now gated on the connection's actual negotiated features (connection.features.use_metadata_id for the Scylla extension, ProtocolVersion.uses_prepared_metadata() for CQL v5+), ensuring the correct wire format is used for each specific connection.
1 parent 80b0c10 commit ade35d8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cassandra/cluster.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,10 +2998,7 @@ def _create_response_future(self, query, parameters, trace, custom_payload,
29982998
message = ExecuteMessage(
29992999
prepared_statement.query_id, query.values, cl,
30003000
serial_cl, fetch_size, paging_state, timestamp,
3001-
skip_meta=(ProtocolVersion.uses_prepared_metadata(self._protocol_version)
3002-
or bool(prepared_statement.result_metadata_id)),
3003-
continuous_paging_options=continuous_paging_options,
3004-
result_metadata_id=prepared_statement.result_metadata_id)
3001+
continuous_paging_options=continuous_paging_options)
30053002
elif isinstance(query, BatchStatement):
30063003
if self._protocol_version < 2:
30073004
raise UnsupportedOperation(
@@ -4619,6 +4616,12 @@ def _query(self, host, message=None, cb=None):
46194616
self._connection = connection
46204617
result_meta = self.prepared_statement.result_metadata if self.prepared_statement else []
46214618

4619+
if self.prepared_statement and isinstance(message, ExecuteMessage):
4620+
use_metadata_id = (ProtocolVersion.uses_prepared_metadata(connection.protocol_version)
4621+
or connection.features.use_metadata_id)
4622+
message.skip_meta = use_metadata_id
4623+
message.result_metadata_id = self.prepared_statement.result_metadata_id if use_metadata_id else None
4624+
46224625
if cb is None:
46234626
cb = partial(self._set_result, host, connection, pool)
46244627

0 commit comments

Comments
 (0)