Skip to content

planner: flaky test in stats test - #65014

Closed
terry1purcell wants to merge 4 commits into
pingcap:masterfrom
terry1purcell:flaky6
Closed

terry1purcell wants to merge 4 commits into
pingcap:masterfrom
terry1purcell:flaky6

Conversation

@terry1purcell

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #63501

Problem Summary:

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.

None

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 12, 2025
@tiprow

tiprow Bot commented Dec 12, 2025

Copy link
Copy Markdown

Hi @terry1purcell. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a flaky test in the statistics test suite by addressing a race condition related to lazy loading of histogram metadata. The fix ensures that the ColAndIdxExistenceMap is fully populated before attempting to load histograms.

Key changes:

  • Added verification steps to ensure table stats are properly cached after h.Update() calls
  • Introduced a second h.Update() call after priming queries to ensure the existence map is populated
  • Added assertions to verify that column metadata is correctly marked as analyzed in the existence map

@codecov

codecov Bot commented Dec 12, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.7071%. Comparing base (8aefecd) to head (68572a5).
⚠️ Report is 33 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #65014        +/-   ##
================================================
- Coverage   70.9290%   69.7071%   -1.2220%     
================================================
  Files          1888       1889         +1     
  Lines        515954     525364      +9410     
================================================
+ Hits         365961     366216       +255     
- Misses       125582     135715     +10133     
+ Partials      24411      23433       -978     
Flag Coverage Δ
integration 44.3323% <33.3333%> (-3.8222%) ⬇️

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 38.5115% <ø> (-20.9135%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@purelind

Copy link
Copy Markdown
Contributor

/retest

@tiprow

tiprow Bot commented Dec 12, 2025

Copy link
Copy Markdown

@purelind: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@terry1purcell
terry1purcell requested a review from 0xPoe December 12, 2025 23:59

@0xPoe 0xPoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@terry1purcell

Copy link
Copy Markdown
Contributor Author

/hold

further investigation on root cause needed

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 13, 2025
@ti-chi-bot

ti-chi-bot Bot commented Dec 13, 2025

Copy link
Copy Markdown

[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 assign terry1purcell for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/statistics sig/planner SIG: Planner and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 13, 2025
@ti-chi-bot ti-chi-bot Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 13, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread pkg/statistics/table.go
Comment on lines +931 to +936
// Also check the existence map as a fallback: if the existence map says the index is analyzed
// but the index object itself doesn't reflect that (e.g., due to lazy loading timing), we should
// still load it. This is particularly important for prefix indexes which might be created with
// lazy loading before the existence map is fully populated.
if t.ColAndIdxExistenceMap.HasAnalyzed(id, true) && !idx.IsFullLoad() {
return idx, true

Copilot AI Dec 16, 2025

Copy link

Choose a reason for hiding this comment

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

The logic in lines 928-930 and 935-937 is redundant. If idx.IsAnalyzed() returns true (meaning idx.StatsVer != Version0), then t.ColAndIdxExistenceMap.HasAnalyzed(id, true) should also return true for a properly maintained existence map. The second check (lines 935-937) will only ever trigger when idx.IsAnalyzed() is false but HasAnalyzed is true, which suggests a data consistency issue between the index object's StatsVer and the existence map.

Consider simplifying this to a single condition or adding a data consistency check/warning if the two states are mismatched.

Suggested change
// Also check the existence map as a fallback: if the existence map says the index is analyzed
// but the index object itself doesn't reflect that (e.g., due to lazy loading timing), we should
// still load it. This is particularly important for prefix indexes which might be created with
// lazy loading before the existence map is fully populated.
if t.ColAndIdxExistenceMap.HasAnalyzed(id, true) && !idx.IsFullLoad() {
return idx, true
// Data consistency check: if the existence map says analyzed but the index does not, log a warning.
if t.ColAndIdxExistenceMap.HasAnalyzed(id, true) && !idx.IsAnalyzed() {
fmt.Printf("[stats] Data inconsistency: index %d existence map says analyzed, but StatsVer is not. Table: %s\n", id, t.Info.Name.O)

Copilot uses AI. Check for mistakes.
@ti-chi-bot

ti-chi-bot Bot commented Dec 16, 2025

Copy link
Copy Markdown

@terry1purcell: 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/mysql-test 68572a5 link true /test mysql-test
pull-lightning-integration-test 68572a5 link true /test pull-lightning-integration-test
pull-unit-test-next-gen 68572a5 link true /test pull-unit-test-next-gen
idc-jenkins-ci-tidb/unit-test 68572a5 link true /test unit-test

Full PR test history. Your PR dashboard.

Details

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/statistics do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants