Skip to content

metricreader: fix data race in BackendReader #619

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

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

djshow832
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close #618

Problem Summary:
After the query results are returned to factors, the results are still updated by the BackendReader, which may cause data race.

What is changed and how it works:
Always generate the query results from scratch and replace the query results all at once so that the query result map won't be updated.

Check List

Tests

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

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change
  • Has tiproxyctl change
  • Other user behavior changes

Release note

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

None

@ti-chi-bot ti-chi-bot bot requested review from bb7133 and xhebox August 3, 2024 01:02
@ti-chi-bot ti-chi-bot bot added the size/XL label Aug 3, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 80.55556% with 7 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@0a52ff1). Learn more about missing BASE report.

Files Patch % Lines
pkg/balance/metricsreader/backend_reader.go 84.84% 3 Missing and 2 partials ⚠️
pkg/balance/metricsreader/query_result.go 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #619   +/-   ##
=======================================
  Coverage        ?   68.92%           
=======================================
  Files           ?       86           
  Lines           ?     7956           
  Branches        ?        0           
=======================================
  Hits            ?     5484           
  Misses          ?     2086           
  Partials        ?      386           
Flag Coverage Δ
unit 68.92% <80.55%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

ti-chi-bot bot commented Aug 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xhebox

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 the lgtm label Aug 5, 2024
Copy link

ti-chi-bot bot commented Aug 5, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-05 02:39:22.919732183 +0000 UTC m=+233292.786831271: ☑️ agreed by xhebox.

@ti-chi-bot ti-chi-bot bot added the approved label Aug 5, 2024
@ti-chi-bot ti-chi-bot bot merged commit dd66b34 into pingcap:main Aug 5, 2024
5 checks passed
@djshow832 djshow832 deleted the fix_qr branch August 5, 2024 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data race between GetQueryResult and mergeQueryResult
3 participants