Skip to content

Conversation

@stevendanna
Copy link
Collaborator

No description provided.

This PR fixes some bugs discovered when trying to increase the test
coverage of the buffered sender unit tests:

- A stream would actually never move into the "overflowing" state.
  Rather it would stay in the "active" state and keep returning a buffer
  capacity error until the registration sent the error back to us, in
  which case it would go straight to overflowed.

- This was papering over another bug in which the overflowing state
  could produce an invalid stream of events.

Here, I add test coverage for the expected state transitions and fix
these bugs by:

  - Dropping buffered messages for streams not in the stream map. This
  works because the stream will be in the stream map from the point of
  the RegisteringStream call and is only removed when the stream finally
  sends the error. Thus any message for a stream not in map represents
  either (1) a message sent to a StreamID before RegisteringStream has
  been called or (2) a message sent to a StreamID after an Error. (1)
  would be a programming error and (2) would be messages that are
  dropped server-side anyway.

  - Re-organizing the code such that it is harder to miss saving the
  stream status back to the status map.

Note any potential bug here only existed on master and thus no release
note is needed.

Epic: CRDB-55217

Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

This changes the flow control in the buffered sender to allow us to
immediately start dropping buffered sends after the first error is
enqueued. This simplifies the code, makes it easier to write assertions
about message ordering, and avoids cases where we have unaccounted for
memory used by messages that were in the queue after an error.

Epic: CRDB-55217
Release note: None
@stevendanna stevendanna force-pushed the ssd/stream-status-early-remove branch from 6339429 to 239a077 Compare October 29, 2025 16:16
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