Skip to content

Strengthen RecyclerBytesStreamOutputTests#140263

Merged
DaveCTurner merged 1 commit intoelastic:mainfrom
DaveCTurner:2026/01/07/RecyclerBytesStreamOutputTests-picky-recycler
Jan 8, 2026
Merged

Strengthen RecyclerBytesStreamOutputTests#140263
DaveCTurner merged 1 commit intoelastic:mainfrom
DaveCTurner:2026/01/07/RecyclerBytesStreamOutputTests-picky-recycler

Conversation

@DaveCTurner
Copy link
Contributor

Today RecyclerBytesStreamOutputTests only covers the case where the
recycler supplies a buffer with zero offset, potentially missing bugs
that only arise with slices of a larger pool of buffers.

This commit strengthens these tests to verify the behaviour when using a
slice of a larger pool, including verification that we never write
outside our buffer and that we do not attempt to read from the buffer
after it is released.

Today `RecyclerBytesStreamOutputTests` only covers the case where the
recycler supplies a buffer with zero offset, potentially missing bugs
that only arise with slices of a larger pool of buffers.

This commit strengthens these tests to verify the behaviour when using a
slice of a larger pool, including verification that we never write
outside our buffer and that we do not attempt to read from the buffer
after it is released.
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed/Network Http and internode communication implementations v9.4.0 labels Jan 7, 2026
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. label Jan 7, 2026
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

Comment on lines +797 to +801
// This seems kinda trappy: a recycler doesn't guarantee anything about the contents of the buffers it supplies, and in
// practice it might contain data left there by the previous user. As used today this is all ok, we always overwrite
// everything eventually in all production usages, but it seems like it might cause problems at some point.
// TODO should we wipe these contents when extending the stream with a seek like this just to be on the safe side?
// In the meantime, for this test only, zero out the buffer contents so that it matches expectedBuffer.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB this bit, should we address this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe introduce friends to seek and skip that perform filling, when in doubt? And rename current seek/skip as unsafeSeek saying there might be garbage in between.

Copy link
Contributor

@mhl-b mhl-b left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +797 to +801
// This seems kinda trappy: a recycler doesn't guarantee anything about the contents of the buffers it supplies, and in
// practice it might contain data left there by the previous user. As used today this is all ok, we always overwrite
// everything eventually in all production usages, but it seems like it might cause problems at some point.
// TODO should we wipe these contents when extending the stream with a seek like this just to be on the safe side?
// In the meantime, for this test only, zero out the buffer contents so that it matches expectedBuffer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe introduce friends to seek and skip that perform filling, when in doubt? And rename current seek/skip as unsafeSeek saying there might be garbage in between.

@DaveCTurner DaveCTurner merged commit c0d5c56 into elastic:main Jan 8, 2026
35 checks passed
@DaveCTurner DaveCTurner deleted the 2026/01/07/RecyclerBytesStreamOutputTests-picky-recycler branch January 8, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Network Http and internode communication implementations Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. >test Issues or PRs that are addressing/adding tests v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants