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

kvflowcontrol: squash data race #104855

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

irfansharif
Copy link
Contributor

@irfansharif irfansharif commented Jun 14, 2023

Fixes #104837.
Fixes #105762.

Release note: None

@irfansharif irfansharif requested a review from a team as a code owner June 14, 2023 06:10
@blathers-crl
Copy link

blathers-crl bot commented Jun 14, 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

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

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


pkg/kv/kvserver/kvflowcontrol/kvflowhandle/kvflowhandle.go line 110 at r1 (raw file):

	// the mutex. To avoid the data race, copy out the pointers first.
	connections := make([]*connectedStream, len(h.mu.connections))
	copy(connections, h.mu.connections)

Admit is on a performance critical path. I think we need a copy-on-write scheme instead of copy-on-read.

@irfansharif irfansharif force-pushed the 230614.handle-race branch from 8ac33ee to edd1e1b Compare July 4, 2023 19:37
Copy link
Contributor Author

@irfansharif irfansharif left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @sumeerbhola)


pkg/kv/kvserver/kvflowcontrol/kvflowhandle/kvflowhandle.go line 110 at r1 (raw file):

Previously, sumeerbhola wrote…

Admit is on a performance critical path. I think we need a copy-on-write scheme instead of copy-on-read.

Done.

@irfansharif irfansharif requested a review from bananabrick July 4, 2023 19:37
Copy link
Contributor

@bananabrick bananabrick left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @irfansharif and @sumeerbhola)


pkg/kv/kvserver/kvflowcontrol/kvflowhandle/kvflowhandle.go line 239 at r2 (raw file):

func (h *Handle) connectStreamLocked(
	ctx context.Context, pos kvflowcontrolpb.RaftLogPosition, stream kvflowcontrol.Stream,

Does each connection have a unique Stream?

Copy link
Contributor Author

@irfansharif irfansharif left a comment

Choose a reason for hiding this comment

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

TFTR.

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @bananabrick and @sumeerbhola)


pkg/kv/kvserver/kvflowcontrol/kvflowhandle/kvflowhandle.go line 239 at r2 (raw file):

Previously, bananabrick (Arjun Nair) wrote…

Does each connection have a unique Stream?

Yes.

@craig
Copy link
Contributor

craig bot commented Jul 4, 2023

👎 Rejected by code reviews

@irfansharif irfansharif dismissed sumeerbhola’s stale review July 4, 2023 23:43

Other reviewer LGTMed.

@irfansharif
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 5, 2023

Build succeeded:

@craig craig bot merged commit c77d127 into cockroachdb:master Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants