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 9 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 40.62500% with 19 lines in your changes missing coverage. Please review.

Project coverage is 54.5071%. Comparing base (e5a8a23) to head (5d3f50a).
Report is 11 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54480         +/-   ##
=================================================
- Coverage   72.8089%   54.5071%   -18.3019%     
=================================================
  Files          1549       1664        +115     
  Lines        436313     604108     +167795     
=================================================
+ Hits         317675     329282      +11607     
- Misses        99059     252987     +153928     
- Partials      19579      21839       +2260     
Flag Coverage Δ
integration 14.7666% <40.6250%> (?)

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 46.1887% <ø> (+0.3481%) ⬆️

@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
func (*StatsCacheImpl) Update() error {
select {
case StatsCacheUpdateChan <- struct{}{}:
default:
Copy link
Member

@hi-rustin hi-rustin Jul 10, 2024

Choose a reason for hiding this comment

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

I think it doesn't solve the issue I mentioned in #54480 (comment).

I believe we need to ensure that once the analysis is finished, we can always load the latest stats for the analyzed tables. Otherwise, there is a chance we will reanalyze them.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with you. Therefore, prior to commencing auto analyze, I will enforce a synchronization of the stats cache.

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
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@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
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Copy link

tiprow bot commented Jul 12, 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 5d3f50a 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 12, 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/unit-test 5d3f50a link true /test unit-test
idc-jenkins-ci-tidb/check_dev_2 5d3f50a link true /test check-dev2
idc-jenkins-ci-tidb/build 5d3f50a link true /test build
idc-jenkins-ci-tidb/check_dev 5d3f50a link true /test check-dev
pull-integration-ddl-test 5d3f50a link true /test pull-integration-ddl-test
idc-jenkins-ci-tidb/mysql-test 5d3f50a link true /test mysql-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.

@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.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

avoid frequantly syncing stats simultaneously
2 participants