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

statistics: avoid frequantly syncing stats simultaneously #54480

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jul 5, 2024

What problem does this PR solve?

Issue Number: close #54481

Problem Summary:

What changed and how does it work?

Now, StatsCacheImpl.Update can sync stats by version from the storage. we have many scenarios to call it. such as domain.loadStatsWorker and Analyze. When customers use lightning, lightning will trigger the multi-analyzed tasks simultaneously. so it also triggers multi StatsCacheImpl.Update simultaneously. it is unnecessary.

add a singleflight for StatsCacheImpl.Update

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 56.0265%. Comparing base (fc47338) to head (e99e4c3).
Report is 60 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54480         +/-   ##
=================================================
- Coverage   72.8103%   56.0265%   -16.7839%     
=================================================
  Files          1553       1674        +121     
  Lines        437420     609590     +172170     
=================================================
+ Hits         318487     341532      +23045     
- Misses        99331     244724     +145393     
- Partials      19602      23334       +3732     
Flag Coverage Δ
integration 37.1075% <83.3333%> (?)

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.6096% <ø> (+6.7483%) ⬆️
@hi-rustin
Copy link
Member

We had some offline discussions that this change could potentially cause a table to be re-analyzed after the analysis is executed. The update method is called after the analysis, but if we only do it once, there is a big chance that the stats cache of the analyzed table will not be updated, which will result in the table being re-queued for analysis.

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2024
@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch from 46ab584 to e74d6ab Compare July 10, 2024 05:00
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 10, 2024
Copy link

ti-chi-bot bot commented Jul 10, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-10 06:35:54.246801334 +0000 UTC m=+425851.482035448: ✖️🔁 reset by hi-rustin.
@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch 3 times, most recently from 19c50c8 to f7ff972 Compare July 10, 2024 08:50
Copy link

ti-chi-bot bot commented Jul 10, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from hawkingrei and additionally assign tangenta for approval(Please ensuring that each of them provides their approval before proceeding). For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch from f7ff972 to cf10f85 Compare July 10, 2024 08:58
@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch from cf10f85 to cfca74a Compare July 10, 2024 09:23
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2024
@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch from 358504f to 9d0c900 Compare July 12, 2024 09:38
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2024
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 15, 2024
Copy link

ti-chi-bot bot commented Jul 15, 2024

PR needs rebase.

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.

@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch 2 times, most recently from 1b7ed28 to 1d80328 Compare July 18, 2024 14:20
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 18, 2024
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei hawkingrei force-pushed the avoid_concurrency_load_stats branch from 0317fc2 to e99e4c3 Compare July 19, 2024 09:01
Copy link

tiprow bot commented Jul 19, 2024

@hawkingrei: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow e99e4c3 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

Copy link

ti-chi-bot bot commented Jul 19, 2024

@hawkingrei: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build e99e4c3 link true /test build
idc-jenkins-ci-tidb/unit-test e99e4c3 link true /test unit-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Copy link

ti-chi-bot bot commented Jul 26, 2024

PR needs rebase.

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
2 participants