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: fix data race during retry of EndTxn after refresh #105480

Merged
merged 1 commit into from
Jun 26, 2023

Conversation

nvanbenschoten
Copy link
Member

Fixes #103687.
Fixes #103247.
Fixes #104791.

This commit avoids a data race between splitEndTxnAndRetrySend and raceTransport by avoiding a mutation of a shared RequestUnion_EndTxn object within an unshared RequestUnion object. The raceTransport makes an effort to copy the BatchRequest's RequestUnion slice, but it does not copy the inner interface, so we can't play tricks to avoid a reallocation of the RequestUnion_EndTxn.

The commit also addresses a similar problem in
retryTxnCommitAfterFailedParallelCommit.

We may be able to fix this in the raceTransport, but doing so would require some reflection magic and this is currently failing CI, so we make the easier change.

Release note: None

Fixes cockroachdb#103687.
Fixes cockroachdb#103247.
Fixes cockroachdb#104791.

This commit avoids a data race between `splitEndTxnAndRetrySend` and
`raceTransport` by avoiding a mutation of a shared `RequestUnion_EndTxn`
object within an unshared `RequestUnion` object. The `raceTransport`
makes an effort to copy the `BatchRequest`'s `RequestUnion` slice, but
it does not copy the inner interface, so we can't play tricks to avoid a
reallocation of the `RequestUnion_EndTxn`.

The commit also addresses a similar problem in
`retryTxnCommitAfterFailedParallelCommit`.

We may be able to fix this in the `raceTransport`, but doing so would
require some reflection magic and this is currently failing CI, so we
make the easier change.

Release note: None
@nvanbenschoten nvanbenschoten requested a review from a team as a code owner June 24, 2023 02:20
@blathers-crl
Copy link

blathers-crl bot commented Jun 24, 2023

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

Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

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

@nvanbenschoten
Copy link
Member Author

TFTR!

bors r=arulajmani

@craig
Copy link
Contributor

craig bot commented Jun 26, 2023

Build succeeded:

@craig craig bot merged commit 15d43bb into cockroachdb:master Jun 26, 2023
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/fix103687 branch July 17, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants