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

test: add lock to avoid data race #46782

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Sep 8, 2023

What problem does this PR solve?

Issue Number: close #46783

Problem Summary:

WARNING: DATA RACE
Read at 0x00c000ac1f58 by goroutine 144:
  slices.insertionSortCmpFunc[go.shape.*uint8]()
      GOROOT/src/slices/zsortanyfunc.go:12 +0xc4
  slices.pdqsortCmpFunc[go.shape.*uint8]()
      GOROOT/src/slices/zsortanyfunc.go:73 +0x6c8
  slices.SortFunc[go.shape.[]*github.com/pingcap/tidb/store/pdtypes.Region,go.shape.*uint8]()
      GOROOT/src/slices/sort.go:28 +0xc6
  github.com/pingcap/tidb/store/pdtypes.(*RegionTree).ScanRange()
      store/pdtypes/region_tree.go:55 +0x7b
  github.com/pingcap/tidb/br/pkg/lightning/backend/local.(*testSplitClient).ScanRegions()
      br/pkg/lightning/backend/local/localhelper_test.go:257 +0x1cf
  github.com/pingcap/tidb/br/pkg/restore/split.PaginateScanRegion.func1()
      br/pkg/restore/split/split.go:106 +0x1b6
  github.com/pingcap/tidb/br/pkg/utils.WithRetry.func1()
      br/pkg/utils/retry.go:57 +0x41
  github.com/pingcap/tidb/br/pkg/utils.WithRetryV2[go.shape.struct {}]()
      br/pkg/utils/retry.go:75 +0xe1
  github.com/pingcap/tidb/br/pkg/utils.WithRetry()
      br/pkg/utils/retry.go:56 +0x8c
  github.com/pingcap/tidb/br/pkg/restore/split.PaginateScanRegion()
      br/pkg/restore/split/split.go:101 +0x28f
  github.com/pingcap/tidb/br/pkg/lightning/backend/local.(*Backend).generateJobForRange()
      br/pkg/lightning/backend/local/local.go:1264 +0x2ec
  github.com/pingcap/tidb/br/pkg/lightning/backend/local.(*Backend).generateAndSendJob.func1()
      br/pkg/lightning/backend/local/local.go:1196 +0x1f9
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      external/org_golang_x_sync/errgroup/errgroup.go:75 +0x76

Previous write at 0x00c000ac1f58 by goroutine 145:
  slices.insertionSortCmpFunc[go.shape.*uint8]()
      GOROOT/src/slices/zsortanyfunc.go:13 +0x1ca
  slices.pdqsortCmpFunc[go.shape.*uint8]()
      GOROOT/src/slices/zsortanyfunc.go:73 +0x6c8
  slices.SortFunc[go.shape.[]*github.com/pingcap/tidb/store/pdtypes.Region,go.shape.*uint8]()
      GOROOT/src/slices/sort.go:28 +0xc6
  github.com/pingcap/tidb/store/pdtypes.(*RegionTree).ScanRange()
      store/pdtypes/region_tree.go:55 +0x7b
  github.com/pingcap/tidb/br/pkg/lightning/backend/local.(*testSplitClient).ScanRegions()
      br/pkg/lightning/backend/local/localhelper_test.go:257 +0x1cf
  github.com/pingcap/tidb/br/pkg/restore/split.PaginateScanRegion.func1()
      br/pkg/restore/split/split.go:106 +0x1b6
  github.com/pingcap/tidb/br/pkg/utils.WithRetry.func1()
      br/pkg/utils/retry.go:57 +0x41
  github.com/pingcap/tidb/br/pkg/utils.WithRetryV2[go.shape.struct {}]()
      br/pkg/utils/retry.go:75 +0xe1
  github.com/pingcap/tidb/br/pkg/utils.WithRetry()
      br/pkg/utils/retry.go:56 +0x8c
  github.com/pingcap/tidb/br/pkg/restore/split.PaginateScanRegion()
      br/pkg/restore/split/split.go:101 +0x28f
  github.com/pingcap/tidb/br/pkg/lightning/backend/local.(*Backend).generateJobForRange()
      br/pkg/lightning/backend/local/local.go:1264 +0x2ec
  github.com/pingcap/tidb/br/pkg/lightning/backend/local.(*Backend).generateAndSendJob.func1()
      br/pkg/lightning/backend/local/local.go:1196 +0x1f9
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      external/org_golang_x_sync/errgroup/errgroup.go:75 +0x76

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 8, 2023
@lance6716 lance6716 added the skip-issue-check Indicates that a PR no need to check linked issue. label Sep 8, 2023
@tiprow
Copy link

tiprow bot commented Sep 8, 2023

Hi @lance6716. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 8, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 8, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tangenta, ywqzzy

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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 8, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 8, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-08 07:54:32.761169415 +0000 UTC m=+2691237.310185402: ☑️ agreed by tangenta.
  • 2023-09-08 07:54:52.127928087 +0000 UTC m=+2691256.676944074: ☑️ agreed by ywqzzy.

@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Merging #46782 (9de233d) into master (fa0c5ce) will decrease coverage by 0.6218%.
Report is 2 commits behind head on master.
The diff coverage is n/a.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #46782        +/-   ##
================================================
- Coverage   73.3027%   72.6809%   -0.6218%     
================================================
  Files          1322       1343        +21     
  Lines        396235     402518      +6283     
================================================
+ Hits         290451     292554      +2103     
- Misses        87261      91397      +4136     
- Partials      18523      18567        +44     
Flag Coverage Δ
integration 27.7638% <ø> (?)
unit 73.3029% <ø> (+0.0002%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 84.9609% <ø> (ø)
br 48.2713% <ø> (-4.3468%) ⬇️
📢 Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap).

@ti-chi-bot ti-chi-bot bot merged commit 431d30f into pingcap:master Sep 8, 2023
11 of 25 checks passed
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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. skip-issue-check Indicates that a PR no need to check linked issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

data race in TestExternalEngine
3 participants