Skip to content

sql: fix data race in MemberOfWithAdminOption#98376

Closed
andyyang890 wants to merge 1 commit intocockroachdb:masterfrom
andyyang890:fix_data_race
Closed

sql: fix data race in MemberOfWithAdminOption#98376
andyyang890 wants to merge 1 commit intocockroachdb:masterfrom
andyyang890:fix_data_race

Conversation

@andyyang890
Copy link
Copy Markdown
Collaborator

Previously, there was a data race in the MemberOfWithAdminOption
function where a context cancellation would cause a transaction
to attempt to clean itself up before a singleflight query using
that transaction had completed.

Fixes #95642
Fixes #96539

Release note: None

Previously, there was a data race in the `MemberOfWithAdminOption`
function where a context cancellation would cause a transaction
to attempt to clean itself up before a singleflight query using
that transaction had completed.

Release note: None
@andyyang890 andyyang890 requested review from a team, ajwerner and rafiss March 10, 2023 16:09
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Mar 10, 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
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

nice find! i wonder if the same issue could be affecting all the other usages of singleflight. (and if so, if the fix should be done in that package)

@ajwerner
Copy link
Copy Markdown
Contributor

This will affect all the singleflights where an outer transaction is used.

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

@andyyang890
Copy link
Copy Markdown
Collaborator Author

nice find! i wonder if the same issue could be affecting all the other usages of singleflight. (and if so, if the fix should be done in that package)

@rafiss I created another PR with an alternative fix that involves mitigating the data race within the singleflight package itself: #98469. Let me know if you would prefer that solution!

cc @ajwerner @andreimatei

@rafiss
Copy link
Copy Markdown
Collaborator

rafiss commented Mar 13, 2023

if possible, could we add a more targeted test that catches this bug? it feels kind of lucky to me that TestBackendDialTLS is the one that caught this. i could imagine that test being refactored in the future, and no longer catching a future regression on this.

@andyyang890
Copy link
Copy Markdown
Collaborator Author

Closed in favor of #98617

@andyyang890 andyyang890 deleted the fix_data_race branch March 17, 2023 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ccl/sqlproxyccl: TestBackendDialTLS failed ccl/sqlproxyccl: TestBackendDialTLS failed due to race condition in catalog nstree

4 participants