-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 racy access to a Transaction proto #15882
Conversation
Slightly -1 on this; the call to Second commit LGTM, nice find! Reviewed 3 of 3 files at r1, 2 of 2 files at r2. pkg/kv/txn_coord_sender.go, line 551 at r1 (raw file):
💯 on removing these ! pkg/kv/txn_coord_sender.go, line 614 at r1 (raw file):
As mentioned in the top level comment: I think the Clone needs to be explained here. pkg/roachpb/data.go, line 718 at r2 (raw file):
👍 Comments from Reviewable |
Well-spotted on the second commit. Share @tamird's opinion on the first. Thanks for the debugging. Looked horrible from what I saw. Reviewed 3 of 3 files at r1, 2 of 2 files at r2. Comments from Reviewable |
b3085fd
to
bf14b01
Compare
reverted to passing by value Review status: 2 of 5 files reviewed at latest revision, 1 unresolved discussion. pkg/kv/txn_coord_sender.go, line 614 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. Comments from Reviewable |
The first commit message is now stale. Reviewed 3 of 3 files at r3, 2 of 2 files at r4. pkg/kv/txn_coord_sender.go, line 614 at r1 (raw file): Previously, andreimatei (Andrei Matei) wrote…
s/might have have/might not have/ pkg/kv/txn_coord_sender.go, line 615 at r3 (raw file):
s/Transaction's/Transactions/ (no apostrophe) Comments from Reviewable |
bf14b01
to
b3b00ed
Compare
completed that commit message Review status: 2 of 5 files reviewed at latest revision, 2 unresolved discussions. pkg/kv/txn_coord_sender.go, line 614 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/kv/txn_coord_sender.go, line 615 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. Comments from Reviewable |
Reviewed 3 of 3 files at r5, 2 of 2 files at r6. Comments from Reviewable |
Fixes cockroachdb#15565 There was a race on accesses to Transaction.ObservedTimestamps because we ended up sharing the ObservedTimestamps between a Transaction proto stored in TxnCoordSender's map and the proto stored in the client.Txn. The sharing happened because the call to TxnCoordSender.cleanupTxnLocked() from TxnCoordSender.send() made a shallow copy of the proto. Now cleanupTxnLocked() clones the proto internally.
Before this patch, Transaction.Clone() was not making a copy of an empty, but with capacity, slice. This seems dangerous to me. There was also some paranoia about it in the DistSender that can be removed if cloning does the right thing.
b3b00ed
to
cf2dbc6
Compare
Fixes #15565
There was a race on accesses to Transaction.ObservedTimestamps because
we ended up sharing the ObservedTimestamps between a Transaction proto
stored in TxnCoordSender's map and the proto stored in the client.Txn.
The sharing happened because the call to
TxnCoordSender.cleanupTxnLocked() from TxnCoordSender.send() made a
shallow copy of the proto.