DRIVER-153: negotiate and implement SCYLLA_USE_METADATA_ID extension#770
Draft
nikagra wants to merge 1 commit intoscylladb:masterfrom
Draft
DRIVER-153: negotiate and implement SCYLLA_USE_METADATA_ID extension#770nikagra wants to merge 1 commit intoscylladb:masterfrom
nikagra wants to merge 1 commit intoscylladb:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Implements negotiation and support for Scylla’s SCYLLA_USE_METADATA_ID protocol extension to enable metadata-id based skip_meta behavior (backporting CQL v5 prepared-statement metadata-id semantics to earlier protocol versions).
Changes:
- Adds
SCYLLA_USE_METADATA_IDparsing fromSUPPORTEDand includes it inSTARTUPwhen negotiated. - Extends protocol encode/decode to read/write
result_metadata_idfor PREPARE/EXECUTE on pre-v5 when the extension is used, and fixes on-wire encoding of_SKIP_METADATA_FLAG. - Updates execution/result handling to conditionally use
skip_metaand to refresh cached prepared metadata when the server reports metadata changes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
cassandra/protocol_features.py |
Adds the SCYLLA_USE_METADATA_ID feature flag and includes it in negotiated STARTUP options. |
cassandra/protocol.py |
Writes _SKIP_METADATA_FLAG in query params; adds pre-v5 extension handling for result_metadata_id in PREPARE/EXECUTE. |
cassandra/cluster.py |
Adjusts when skip_meta is enabled and updates cached prepared metadata/id on METADATA_CHANGED responses. |
tests/unit/test_protocol_features.py |
Adds unit tests for feature parsing and STARTUP option inclusion. |
tests/unit/test_protocol.py |
Adds unit tests for skip-meta flag encoding and metadata-id handling in pre-v5 PREPARE/EXECUTE paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Scylla's SCYLLA_USE_METADATA_ID protocol extension (backport of CQL v5
prepared-statement metadata IDs to earlier protocol versions) allows the
driver to skip sending full result metadata on every EXECUTE request.
The server notifies the driver via the METADATA_CHANGED flag whenever
the result schema changes, at which point the driver updates its cached
metadata before deserialising the response.
Changes:
- protocol_features.py: parse SCYLLA_USE_METADATA_ID from SUPPORTED and
include it in the STARTUP frame when negotiated
- protocol.py:
* fix _write_query_params to actually write _SKIP_METADATA_FLAG on the
wire (it was stored on the message but never sent — dead code before)
* recv_results_prepared: read result_metadata_id for Scylla extension
(pre-v5) in addition to standard protocol v5+
* ExecuteMessage.send_body: send result_metadata_id for Scylla
extension (pre-v5) when it is set
- cluster.py:
* ExecuteMessage is built with safe defaults (skip_meta=False,
result_metadata_id=None); both are set in _query() after borrowing
the connection, gated on connection.features.use_metadata_id and on
the prepared statement actually having a result_metadata_id (so a
statement prepared before the extension was available, or on a node
that doesn't support it, never gets skip_meta=True with no id)
* _set_result: update prepared_statement.result_metadata and
result_metadata_id when the server signals METADATA_CHANGED in an
EXECUTE response, keeping the driver's cached metadata in sync;
uses getattr to safely handle FastResultMessage (Cython decoder)
ade35d8 to
f42e225
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
SCYLLA_USE_METADATA_IDScylla CQL protocol extension (DRIVER-153), which backports the prepared-statement metadata-ID mechanism from CQL v5 to earlier protocol versions.When the extension is negotiated:
skip_meta=True)METADATA_CHANGEDflag and includes the new metadata ID + new column metadata in the response — the driver picks this up and updates its cached metadata automaticallyChanges
cassandra/protocol_features.pyUSE_METADATA_ID = "SCYLLA_USE_METADATA_ID"constant anduse_metadata_idfield toProtocolFeaturescassandra/protocol.py_write_query_paramsnow actually writes_SKIP_METADATA_FLAGon the wire — it was stored on_QueryMessagebut never sent (effectively dead code)recv_results_prepared: readresult_metadata_idfor Scylla extension (pre-v5) in addition to standard CQL v5+ExecuteMessage.send_body: sendresult_metadata_idfor Scylla extension (pre-v5) when setcassandra/cluster.pyskip_metais nowTrueonly when safe: CQL v5 is used orSCYLLA_USE_METADATA_IDwas negotiated (proxied by a non-Noneresult_metadata_idon the prepared statement). OtherwiseFalse— always fetch full metadata (safest option)._set_result: when the EXECUTE response contains a newresult_metadata_id(METADATA_CHANGED), updateprepared_statement.result_metadataandresult_metadata_idto keep the cached metadata in syncTest plan
627 passed, 97 skipped)