Skip to content

logictest: fix potential race with async statements#79925

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
AlexTalks:logictest_asycn_statements_fix_race
Apr 14, 2022
Merged

logictest: fix potential race with async statements#79925
craig[bot] merged 1 commit intocockroachdb:masterfrom
AlexTalks:logictest_asycn_statements_fix_race

Conversation

@AlexTalks
Copy link
Copy Markdown
Contributor

@AlexTalks AlexTalks commented Apr 13, 2022

While statements in logictests with the async option start a new
goroutine to execute the statement via db.Exec(..), there was a
potential race because the database handle t.db was shared without a
mutex, and could be changed by other operations such as user <newuser>.
This change fixes the issue by capturing a reference to the
database handle prior to starting the goroutine, thus eliminating the
porential race.

Release note: None

While statements in logictests with the `async` option start a new
goroutine to execute the statement via `db.Exec(..)`, there was a
potential race because the database handle `t.db` was shared without a
mutex, and could be changed by other operations such as `user
<newuser>`. This change fixes the issue by capturing a reference to the
database handle prior to starting the goroutine, thus eliminating the
porential race.

Release note: None
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@AlexTalks AlexTalks requested review from nvb and yuzefovich April 13, 2022 21:19
Copy link
Copy Markdown
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:

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

Copy link
Copy Markdown
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.

We also want to backport this to 22.1, right?

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

Copy link
Copy Markdown
Contributor Author

@AlexTalks AlexTalks left a comment

Choose a reason for hiding this comment

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

Yes - I believe we can still backport test-only changes like this without issue? I believe the backport for #77876 may need to wait some time (though I hope to merge to master sooner).

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

@AlexTalks
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 14, 2022

Build succeeded:

@craig craig bot merged commit cba5cd1 into cockroachdb:master Apr 14, 2022
@AlexTalks AlexTalks deleted the logictest_asycn_statements_fix_race branch April 14, 2022 22:06
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.

3 participants