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: fix wrong NDV in the global stats when to disable async-merge-global-stats #53762

Merged
merged 10 commits into from
Jun 4, 2024

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jun 3, 2024

What problem does this PR solve?

Issue Number: close #53752

Problem Summary:

What changed and how does it work?

blockMergeGlobalStats doesn't notice that FMSketch contains empty objectives in all partition's stats. so we need to find nil to init global rightly.

Check List

Tests

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

run as the PR's description.

  • 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

@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. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked labels Jun 3, 2024
@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. labels Jun 3, 2024
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.2464%. Comparing base (073f746) to head (2d61093).
Report is 19 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #53762         +/-   ##
=================================================
- Coverage   72.4954%   56.2464%   -16.2490%     
=================================================
  Files          1506       1626        +120     
  Lines        431172     607432     +176260     
=================================================
+ Hits         312580     341659      +29079     
- Misses        99191     242521     +143330     
- Partials      19401      23252       +3851     
Flag Coverage Δ
integration 37.5768% <100.0000%> (?)
unit 71.7525% <50.0000%> (+0.2706%) ⬆️

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

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

@hawkingrei hawkingrei requested a review from qw4990 June 4, 2024 03:12
@@ -959,3 +959,75 @@ func TestGlobalStatsAndSQLBindingWithConcurrency(t *testing.T) {
tk.MustExec("set global tidb_merge_partition_stats_concurrency=2")
testGlobalStatsAndSQLBinding(tk)
}

func TestBlockCheckFMSketch(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

It seems that even if I revert your change I can still pass the tests. So maybe the test case doesn't cover the change?

Copy link
Member Author

Choose a reason for hiding this comment

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

You should disable the tidb_enable_async_merge_global_stats.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I have. I've run the TestBlockCheckFMSketch.

  1. I revert your change.
  2. I ran the TestBlockCheckFMSketch, and it still passed.

Copy link
Member

@Rustin170506 Rustin170506 Jun 4, 2024

Choose a reason for hiding this comment

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

image

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 find this problem, only it is reproduced in the real tikv.

pkg/statistics/handle/globalstats/global_stats_test.go Outdated Show resolved Hide resolved
pkg/statistics/handle/globalstats/global_stats_test.go Outdated Show resolved Hide resolved
pkg/statistics/handle/globalstats/global_stats_test.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 4, 2024
Copy link

ti-chi-bot bot commented Jun 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hi-rustin, winoros

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 Jun 4, 2024
Copy link

ti-chi-bot bot commented Jun 4, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-04 07:23:58.487654752 +0000 UTC m=+3365992.244790323: ☑️ agreed by winoros.
  • 2024-06-04 07:32:35.42284234 +0000 UTC m=+3366509.179977916: ☑️ agreed by hi-rustin.

@Rustin170506
Copy link
Member

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 9c1a45a into pingcap:master Jun 4, 2024
23 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #53803.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 4, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 4, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #53804.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #53805.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #53806.

ti-chi-bot bot pushed a commit that referenced this pull request Jun 5, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jun 5, 2024
@hawkingrei hawkingrei deleted the fix_status branch June 5, 2024 11:17
ti-chi-bot bot pushed a commit that referenced this pull request Jun 7, 2024
hawkingrei pushed a commit to hawkingrei/tidb that referenced this pull request Jul 1, 2024
hawkingrei pushed a commit to hawkingrei/tidb that referenced this pull request Jul 1, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrong NDV in the global stats when to disable async-merge-global-stats
4 participants