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

Fix gtest data race detected by tsan check #8565

Merged
merged 15 commits into from
Dec 22, 2023

Conversation

yibin87
Copy link
Contributor

@yibin87 yibin87 commented Dec 22, 2023

What problem does this PR solve?

Issue Number: ref #8285 #8553

Problem Summary:
In #8553, mutex is added to protect prepareMPPTasks. However, the DAGRequestBuilder parameter is constructed outside the protection, and the context's index will be updated during the construction. This is caused by the two-phase compilation: first for operators without exchange, second for exchange operators. Thus adjust the mutex protection scope in this pr.

Set server's mock storage at beginning to avoid harmless data races.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 22, 2023
@yibin87
Copy link
Contributor Author

yibin87 commented Dec 22, 2023

/run-all-tests

@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 22, 2023
@yibin87
Copy link
Contributor Author

yibin87 commented Dec 22, 2023

/run-all-tests

@@ -147,11 +147,16 @@ class ComputeServerRunner : public DB::tests::MPPTaskTestUtils
BlockInputStreamPtr stream;
try
{
auto tasks = prepareMPPTasks(
Copy link
Contributor

Choose a reason for hiding this comment

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

how about prepareMPPTasks([&] () { return context.xxx }, properties)?
and then DAGRequestBuilder will under lock

Copy link
Contributor

@SeaRise SeaRise Dec 22, 2023

Choose a reason for hiding this comment

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

Maybe MockDAGRequestContext::index should be atomic_size_t?

Copy link
Contributor Author

@yibin87 yibin87 Dec 22, 2023

Choose a reason for hiding this comment

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

Sounds great, I'll change the function signature. Use atomic_size_t can't totally solve the issue here, since builder will reset it to 0 at the end.

Copy link
Contributor

@SeaRise SeaRise Dec 22, 2023

Choose a reason for hiding this comment

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

Maybe thread_local size_t index? but seems that mac doesn't support thread_local :(

Signed-off-by: yibin <[email protected]>
@yibin87
Copy link
Contributor Author

yibin87 commented Dec 22, 2023

/run-all-tests

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 22, 2023
@yibin87
Copy link
Contributor Author

yibin87 commented Dec 22, 2023

/run-integration-test

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added the lgtm label Dec 22, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 22, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SeaRise, windtalker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 22, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 22, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-22 07:07:46.854092432 +0000 UTC m=+1203957.891319355: ☑️ agreed by SeaRise.
  • 2023-12-22 08:34:37.008531852 +0000 UTC m=+1209168.045758764: ☑️ agreed by windtalker.

@yibin87
Copy link
Contributor Author

yibin87 commented Dec 22, 2023

/run-integration-test

@ti-chi-bot ti-chi-bot bot merged commit ddf3f97 into pingcap:master Dec 22, 2023
6 checks passed
JaySon-Huang pushed a commit to JaySon-Huang/tiflash that referenced this pull request Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants