Skip to content

Ensure a Message's Response streamId is always set#4936

Open
frankgh wants to merge 3 commits into
apache:trunkfrom
frankgh:CASSANDRA-21508
Open

Ensure a Message's Response streamId is always set#4936
frankgh wants to merge 3 commits into
apache:trunkfrom
frankgh:CASSANDRA-21508

Conversation

@frankgh

@frankgh frankgh commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

patch by Francisco Guerrero; reviewed by TBD for CASSANDRA-21508

patch by Francisco Guerrero; reviewed by TBD for CASSANDRA-21508
ErrorMessage errorMessage = ErrorMessage.fromException(cause, handler);
// No request in scope at the channel level; a WrappedException cause carries the frame's stream id
// and overrides this 0 fallback, otherwise the channel is torn down for fatal errors.
ErrorMessage errorMessage = ErrorMessage.fromException(cause, 0, handler);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably not use a valid streamId as a placeholder you intend to overwrite later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a very good point. I will update it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to consider here is that we won't always overwrite the stream id. I considered using the sentinel value, but this would trip the assertion during the encoding. So we'll need to keep a valid value here.

The cases where the streamId will not be overwritten are:

  • ExceptionHandlers.java:81 / PreV5Handlers.java:342 : This occurs during channel negotiations (SSL/TLS handshake failures) and a stream ID is not available
  • Unexpected non-wrapped pipeline throwables where no frame/stream ID exists at all

Everything else arrives in a wrapped exception and carries a real stream ID :

  • CQLMessageHandler:517 : extracted.streamId() (best-effort)
  • CQLMessageHandler:534 (oversized auth) : header.streamId
  • CQLMessageHandler:725 (corrupt frame) : NO_REQUEST_STREAM_ID — explicit, the one true context-free CQL path

I think keeping 0 for the NO_REQUEST_STREAM_ID is reasonable because the only sources of missing stream ids are when an error occurs before a stream id is available or when a a corrupt frame does not allow us to extract the stream id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants