Skip to content

pkg/ddl/tests/tiflash: stabilize flaky TestTiFlashProgressAfterAvailableForPartitionTable#67871

Open
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_9d2476f7b8f6-a2
Open

pkg/ddl/tests/tiflash: stabilize flaky TestTiFlashProgressAfterAvailableForPartitionTable#67871
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_9d2476f7b8f6-a2

Conversation

@flaky-claw

@flaky-claw flaky-claw commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #67563

Problem Summary:
Flaky test TestTiFlashProgressAfterAvailableForPartitionTable in pkg/ddl/tests/tiflash intermittently fails, so this PR stabilizes that path.

What changed and how does it work?

Root Cause

TEST_ISSUE — fixed sleeps assumed async TiFlash progress-cache refresh completed, causing stale-read assertion windows.

Fix

replacing fixed-delay assertions with require.Eventually is necessary to synchronize the test with the real async refresh boundary.

Verification

Spec:

  • target: pkg/ddl/tests/tiflash :: TestTiFlashProgressAfterAvailableForPartitionTable
  • strategy: tidb.go_flaky.default
  • plan mode: BASELINE_ONLY
  • requirements: required case must execute; no skip; repeat count = 1
  • baseline gates: required_flaky_gate, build_safety_gate, intent_guard_gate

Observed result:

  • status: passed
  • required case executed: yes
  • submission decision: ALLOWED
  • scope debt present: yes

Gate checklist:

  • Required flaky gate: PASS
  • Build safety gate: PASS
  • Intent guard gate: PASS
  • Repo-wide advisory gate: SKIPPED
  • Feedback specific gate: SKIPPED

Commands:

  • go test -json ./pkg/ddl/tests/tiflash -run '^TestTiFlashProgressAfterAvailableForPartitionTable$' -count=1
  • go test -json ./pkg/ddl/tests/tiflash -count=1
  • make build

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

Fixes #67563

Summary by CodeRabbit

  • Tests
    • Improved TiFlash test stability by replacing fixed wait times with polling-based verification for progress checks.

Review Change Stack

@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 18, 2026
@pantheon-ai

pantheon-ai Bot commented Apr 18, 2026

Copy link
Copy Markdown

Review failed due to infrastructure/execution failure after retries. Please re-trigger review.

(Branch flakyfixer/case_9d2476f7b8f6-a2 could not be resolved — it is not present on the pingcap/tidb remote, no matching fork was found, and gh pr checkout 67871 also failed. The sandbox environment preparation exhausted all 3 attempts.)

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 18, 2026
@ti-chi-bot

ti-chi-bot Bot commented Apr 18, 2026

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 wjhuang2016 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

@tiprow

tiprow Bot commented Apr 18, 2026

Copy link
Copy Markdown

Hi @flaky-claw. 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.

@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 40d02565-3418-405c-9a60-675ea057ceb9

📥 Commits

Reviewing files that changed from the base of the PR and between f469c33 and 0ce24e7.

📒 Files selected for processing (1)
  • pkg/ddl/tests/tiflash/ddl_tiflash_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/ddl/tests/tiflash/ddl_tiflash_test.go

📝 Walkthrough

Walkthrough

Test function TestTiFlashProgressAfterAvailableForPartitionTable is refactored to replace fixed time.Sleep calls with a waitProgress polling helper that uses require.Eventually to repeatedly check TiFlash sync progress from cache until the expected value is observed.

Changes

TiFlash Progress Test Stabilization

Layer / File(s) Summary
Replace sleep-based assertions with polling
pkg/ddl/tests/tiflash/ddl_tiflash_test.go
Test stores partition ID once and introduces waitProgress closure using require.Eventually to poll infosync.GetTiFlashProgressFromCache(partitionID) until cached progress equals expected values (0 and 1), replacing separate time.Sleep + direct assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • pingcap/tidb#68122: Modifies the same test function TestTiFlashProgressAfterAvailable in pkg/ddl/tests/tiflash/ddl_tiflash_test.go to improve test stability through setup/execution changes and TiFlash progress wait mechanics.
  • pingcap/tidb#67797: Replaces fixed time.Sleep-based progress checks with polling against infosync.GetTiFlashProgressFromCache(...) in TiFlash test assertions, addressing similar flakiness patterns.

Suggested labels

approved, lgtm

Suggested reviewers

  • wjhuang2016
  • D3Hunter
  • OliverS929

Poem

🐰 A test that sleeps and hopes is fraught,
But polling waits—a steadier thought!
With Eventually and cache reread,
No more flakes—stability ahead!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: stabilizing a flaky test by replacing fixed sleeps with polling in TestTiFlashProgressAfterAvailableForPartitionTable.
Linked Issues check ✅ Passed The PR successfully addresses issue #67563 by replacing fixed-delay assertions with polling via waitProgress helper to synchronize with asynchronous TiFlash progress-cache refresh.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to stabilizing the flaky test; only test file modifications with no unrelated alterations to source code or other tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/ddl/tests/tiflash/main_test.go`:
- Around line 28-37: TestMain currently enables intest.InTest,
intest.EnableAssert, and intest.EnableInternalCheck globally which mutates
process-wide test behavior; restrict this to only the tests that need the
TiFlash progress cache synchronization (or add a clear justification comment).
Remove the global enables from TestMain and instead set them inside the specific
test(s) that require them (e.g., in the TiFlash progress-cache flaky test),
wrapping the change in a helper that saves the previous values, sets
intest.InTest/intest.EnableAssert/intest.EnableInternalCheck, runs the test
logic, then restores the original values; alternatively, if keeping in TestMain
is truly required, add a concise comment explaining why the entire package must
have these flags enabled and document the risk. Ensure references: TestMain,
intest.InTest, intest.EnableAssert, intest.EnableInternalCheck, and the TiFlash
progress cache test when applying the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 60c65072-929e-414f-918e-492b3501fcd8

📥 Commits

Reviewing files that changed from the base of the PR and between e3f45e4 and f469c33.

📒 Files selected for processing (2)
  • pkg/ddl/tests/tiflash/ddl_tiflash_test.go
  • pkg/ddl/tests/tiflash/main_test.go

Comment thread pkg/ddl/tests/tiflash/main_test.go Outdated
@codecov

codecov Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.8585%. Comparing base (daf0a27) to head (0ce24e7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67871        +/-   ##
================================================
+ Coverage   76.3085%   76.8585%   +0.5499%     
================================================
  Files          2041       2051        +10     
  Lines        563503     570742      +7239     
================================================
+ Hits         430001     438664      +8663     
+ Misses       132586     130387      -2199     
- Partials        916       1691       +775     
Flag Coverage Δ
integration 46.0643% <ø> (+6.2852%) ⬆️

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

Components Coverage Δ
dumpling 60.4679% <ø> (ø)
parser ∅ <ø> (∅)
br 65.1554% <0.0000%> (+2.3401%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yinsustart
yinsustart force-pushed the flakyfixer/case_9d2476f7b8f6-a2 branch from f469c33 to 0ce24e7 Compare May 27, 2026 14:54
@flaky-claw

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented May 27, 2026

Copy link
Copy Markdown

@flaky-claw: 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.

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.

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: TestTiFlashProgressAfterAvailableForPartitionTable in pkg/ddl/tests/tiflash

1 participant