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: GCStats should not wrongly remove record of an existing table #58108

Merged
merged 7 commits into from
Dec 11, 2024

Conversation

winoros
Copy link
Member

@winoros winoros commented Dec 9, 2024

What problem does this PR solve?

Issue Number: close #57983

Problem Summary:

When we try to delete the stats. We need to first ensure that the table is already deleted.

What changed and how does it work?

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.

修复统计信息垃圾回收时可能错误的删除统计信息记录的问题
Fix the issue that the stat' GC process may wrongly delete records of statistics.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/planner SIG: Planner labels Dec 9, 2024
@winoros winoros changed the title statistics: GCStats should not wrongly remove record of an existing t… statistics: GCStats should not wrongly remove record of an existing table Dec 9, 2024
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.9148%. Comparing base (2a1f646) to head (4136245).
Report is 196 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58108        +/-   ##
================================================
+ Coverage   73.2116%   73.9148%   +0.7032%     
================================================
  Files          1675       1706        +31     
  Lines        461921     470345      +8424     
================================================
+ Hits         338180     347655      +9475     
+ Misses       102981     101257      -1724     
- Partials      20760      21433       +673     
Flag Coverage Δ
integration 46.0066% <0.0000%> (?)
unit 72.4096% <100.0000%> (+0.0646%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 46.0089% <ø> (+0.0150%) ⬆️

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 10, 2024
Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

Thanks!

rows, _, err := util.ExecRows(sctx, "select is_index, hist_id from mysql.stats_histograms where table_id = %?", physicalID)
if err != nil {
return errors.Trace(err)
}
// The table has already been deleted in stats and acknowledged to all tidb,
// we can safely remove the meta info now.
if len(rows) == 0 {
if len(rows) == 0 && !ok {
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is never gonna be true.

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 10, 2024
Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

Thanks! :shipit:

Some nits.

/hold

pkg/statistics/handle/storage/gc.go Outdated Show resolved Hide resolved
pkg/statistics/handle/storage/gc.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 11, 2024
@winoros
Copy link
Member Author

winoros commented Dec 11, 2024

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 11, 2024
@winoros winoros removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 11, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 11, 2024
Copy link

ti-chi-bot bot commented Dec 11, 2024

@winoros: You cannot manually add or delete the reviewing state labels, only I and the tursted members have permission to do so.

In response to removing label named needs-1-more-lgtm.

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 ti-community-infra/tichi repository.

@winoros
Copy link
Member Author

winoros commented Dec 11, 2024

/merge

Copy link

ti-chi-bot bot commented Dec 11, 2024

@winoros: We have migrated to builtin LGTM and approve plugins for reviewing.

👉 Please use /approve when you want approve this pull request.

The changes announcement: LGTM plugin changes

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 11, 2024
Copy link

ti-chi-bot bot commented Dec 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-10 02:18:18.736568677 +0000 UTC m=+318488.825371220: ☑️ agreed by hawkingrei.
  • 2024-12-10 03:25:19.431683264 +0000 UTC m=+322509.520485806: ✖️🔁 reset by Rustin170506.
  • 2024-12-11 10:16:56.497600094 +0000 UTC m=+433606.586402631: ☑️ agreed by Rustin170506.
  • 2024-12-11 11:46:21.686258117 +0000 UTC m=+438971.775060659: ☑️ agreed by hawkingrei.

@winoros
Copy link
Member Author

winoros commented Dec 11, 2024

/retest

Copy link

ti-chi-bot bot commented Dec 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, hawkingrei, qw4990, Rustin170506

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 merged commit d5b6b69 into pingcap:master Dec 11, 2024
24 checks passed
@winoros winoros deleted the fix-gc-stats branch December 11, 2024 13:45
@hawkingrei
Copy link
Member

/cherrypick release-7.5

@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-7.5: #58195.

In response to this:

/cherrypick release-7.5

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 12, 2024
hawkingrei pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 12, 2024
@lilinghai lilinghai added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Jan 8, 2025
@ti-chi-bot
Copy link
Member

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

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-8.5 Should cherry pick this PR to release-8.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

stats' gc process wrongly deletes the statistics of tables that are not analyzed in extreme situation
7 participants