Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: shallow copy {,Reverse}ScanResponse.{BatchResponses,ColBatches} when pipelining #121789

Merged

Conversation

nvanbenschoten
Copy link
Member

Fixes #121759.

This commit updates ScanResponse and ReverseScanResponse's ShallowCopy implementations to perform a shallow copy of the BatchResponses and ColBatches slices. These are both slices of data array slices which can be mutated by popBatch, even though the underlying data slices are immutable.

Release note: None

…hen pipelining

Fixes cockroachdb#121759.

This commit updates ScanResponse and ReverseScanResponse's ShallowCopy
implementations to perform a shallow copy of the BatchResponses and
ColBatches slices. These are both slices of data array slices which can
be mutated by `popBatch`, even though the underlying data slices are
immutable.

Release note: None
@nvanbenschoten nvanbenschoten added the backport-24.1.x Flags PRs that need to be backported to 24.1. label Apr 4, 2024
@nvanbenschoten nvanbenschoten requested a review from a team as a code owner April 4, 2024 18:19
Copy link

blathers-crl bot commented Apr 4, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nvanbenschoten
Copy link
Member Author

These are both slices of data array slices which can be mutated by popBatch, even though the underlying data slices are immutable.

@yuzefovich could you confirm that the underlying data slices in {,Reverse}ScanResponse.BatchResponses are treated as immutable, even though the outer slice is mutated during query execution (by popBatch)?

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm:

Yes, each []byte slice shouldn't be modified later - we only modify [][]byte to allow for faster GC of no longer needed []byte slices.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani)

@nvanbenschoten
Copy link
Member Author

TFTR!

bors r+

@craig craig bot merged commit 22cdfdf into cockroachdb:master Apr 4, 2024
22 checks passed
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/batchRespRace branch April 5, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-24.1.x Flags PRs that need to be backported to 24.1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logictest: data race around KV batches
3 participants