Skip to content

pkg/ddl/tests/tiflash: stabilize flaky TestTiFlashBackoff#68115

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_dcfa7f942074-a2
May 14, 2026
Merged

pkg/ddl/tests/tiflash: stabilize flaky TestTiFlashBackoff#68115
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_dcfa7f942074-a2

Conversation

@flaky-claw

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

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #68044

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

What changed and how does it work?

Root Cause

TestTiFlashBackoff was a test teardown race: it returned after replica availability became true even though the TiFlash poller can still perform later available-table progress refreshes against the mock status server.

Fix

The added progress-cache witness is necessary to prove that post-availability polling both happened and then stopped before teardown, which closes the reviewer-reported quiescence gap without changing product code.

Verification

Spec:

  • target: pkg/ddl/tests/tiflash :: TestTiFlashBackoff
  • 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
  • feedback surface source: baseline_only

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 '^TestTiFlashBackoff$' -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 #68044

Summary by CodeRabbit

  • Tests
    • Improved TestTiFlashBackoff test reliability by directly controlling TiFlash state and removing fragile mocking mechanisms. Enhanced validation to ensure TiFlash replica progress is properly refreshed when availability changes occur and polling is active.

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed labels Apr 29, 2026
@pantheon-ai

pantheon-ai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 29, 2026
@tiprow

tiprow Bot commented Apr 29, 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 29, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The test TestTiFlashBackoff is refactored to eliminate flakiness by replacing failpoint-based polling manipulation with direct session control and state-driven assertions. The test now explicitly manages TiFlash sync status, waits for replica availability using a dedicated helper, and validates progress cache updates deterministically.

Changes

Cohort / File(s) Summary
TiFlash Backoff Test Refactoring
pkg/ddl/tests/tiflash/ddl_tiflash_test.go
Test updated to use explicit session creation instead of testkit, removes failpoint-based polling manipulation, directly controls mocked TiFlash state via ResetSyncStatus, waits for availability with WaitTablesAvailableWithTableName, and validates progress cache updates using require.Never assertions instead of timing-based expectations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • pingcap/tidb#67797: Modifies the same TiFlash DDL test file, replacing testkit with explicit sessions and converting timing-based waits to state-based assertions.
  • pingcap/tidb#67397: Introduces the WaitTablesAvailableWithTableName helper function directly utilized by this PR's test modifications.

Suggested labels

size/S, approved, lgtm

Suggested reviewers

  • wjhuang2016
  • expxiaoli
  • tiancaiamao

Poem

🐰 A test that flaked too often, now stands tall,
With states explicit and polling's call,
No failpoints needed, just steady ground,
Where TiFlash progress is surely found!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title check ✅ Passed The title clearly and specifically describes the primary change: stabilizing a flaky test in the tiflash ddl tests package.
Description check ✅ Passed The description comprehensively covers root cause, fix, and verification with proper issue linking (close #68044) and checklist completion.
Linked Issues check ✅ Passed The PR successfully addresses issue #68044 by eliminating the teardown race in TestTiFlashBackoff through a progress-cache witness, stabilizing the flaky test without product code changes.
Out of Scope Changes check ✅ Passed All changes are scoped to stabilizing TestTiFlashBackoff test as required; no unrelated modifications present.

✏️ 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

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Command failed


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.3218%. Comparing base (c391a01) to head (cb5330a).
⚠️ Report is 56 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68115        +/-   ##
================================================
+ Coverage   77.7579%   78.3218%   +0.5639%     
================================================
  Files          1990       2022        +32     
  Lines        551594     572774     +21180     
================================================
+ Hits         428908     448607     +19699     
+ Misses       121766     121464       -302     
- Partials        920       2703      +1783     
Flag Coverage Δ
integration 48.5248% <ø> (+8.7229%) ⬆️

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

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

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

🧹 Nitpick comments (1)
pkg/ddl/tests/tiflash/ddl_tiflash_test.go (1)

777-804: Guarantee poll shutdown on all exit paths

ddl.DisableTiFlashPoll is only called at Line 799. If any require.* before that fails, teardown still closes the mock status server while polling may remain active, which can re-open the teardown race on failure paths. Register cleanup immediately after Line 777 so poll is always disabled.

Proposed fix
  ddl.EnableTiFlashPoll(s.dom.DDL())
+ t.Cleanup(func() {
+ 	ddl.DisableTiFlashPoll(s.dom.DDL())
+ })

  // 1, 1.5, 2.25, 3.375, 5.5625
  // (1), 1, 1, 2, 3, 5
  time.Sleep(ddl.PollTiFlashInterval * 5)
@@
- ddl.DisableTiFlashPoll(s.dom.DDL())
+ ddl.DisableTiFlashPoll(s.dom.DDL())

As per coding guidelines: “Keep test changes minimal and deterministic; avoid broad golden/testdata churn unless required.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/ddl/tests/tiflash/ddl_tiflash_test.go` around lines 777 - 804, After
calling ddl.EnableTiFlashPoll(s.dom.DDL()), register a test cleanup to always
call ddl.DisableTiFlashPoll(s.dom.DDL()) so polling is disabled on all exit
paths (use t.Cleanup to register the call immediately after EnableTiFlashPoll).
This guarantees shutdown even if earlier require.* assertions fail; you can keep
or remove the later explicit ddl.DisableTiFlashPoll call at Line 799 but the
cleanup must be added right after EnableTiFlashPoll to ensure deterministic
teardown.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/ddl/tests/tiflash/ddl_tiflash_test.go`:
- Around line 777-804: After calling ddl.EnableTiFlashPoll(s.dom.DDL()),
register a test cleanup to always call ddl.DisableTiFlashPoll(s.dom.DDL()) so
polling is disabled on all exit paths (use t.Cleanup to register the call
immediately after EnableTiFlashPoll). This guarantees shutdown even if earlier
require.* assertions fail; you can keep or remove the later explicit
ddl.DisableTiFlashPoll call at Line 799 but the cleanup must be added right
after EnableTiFlashPoll to ensure deterministic teardown.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c27cd877-acd9-41da-a898-1b3840a5050e

📥 Commits

Reviewing files that changed from the base of the PR and between c391a01 and cb5330a.

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

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

✅ Code looks good. No issues found.

@yinsustart

Copy link
Copy Markdown

/check-issue-triage-complete

@tiprow

tiprow Bot commented May 3, 2026

Copy link
Copy Markdown

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

@yinsustart
yinsustart requested review from D3Hunter and bb7133 May 6, 2026 00:40
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 6, 2026
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 6, 2026
@ti-chi-bot

ti-chi-bot Bot commented May 6, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-05-06 02:45:14.025102422 +0000 UTC m=+235786.898452404: ☑️ agreed by YangKeao.
  • 2026-05-06 03:08:16.051341562 +0000 UTC m=+237168.924691544: ☑️ agreed by D3Hunter.

@yinsustart

Copy link
Copy Markdown

/retest

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

LGTM

@ti-chi-bot

ti-chi-bot Bot commented May 7, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bb7133, D3Hunter, YangKeao

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

The pull request process is described 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 May 7, 2026

Copy link
Copy Markdown

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

@yinsustart

Copy link
Copy Markdown

/test pull-unit-test-ddlv1

@tiprow

tiprow Bot commented May 7, 2026

Copy link
Copy Markdown

@yinsustart: 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:

/test pull-unit-test-ddlv1

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.

@flaky-claw

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented May 9, 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.

@flaky-claw

Copy link
Copy Markdown
Contributor Author

/test pull-unit-test-ddlv1

@tiprow

tiprow Bot commented May 9, 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:

/test pull-unit-test-ddlv1

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.

@yinsustart

Copy link
Copy Markdown

/retest

@tiprow

tiprow Bot commented May 10, 2026

Copy link
Copy Markdown

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

@yinsustart

Copy link
Copy Markdown

/retest

@tiprow

tiprow Bot commented May 10, 2026

Copy link
Copy Markdown

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

@yinsustart

Copy link
Copy Markdown

/test pull-br-integration-test

@tiprow

tiprow Bot commented May 11, 2026

Copy link
Copy Markdown

@yinsustart: 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:

/test pull-br-integration-test

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.

@yinsustart

Copy link
Copy Markdown

/retest

@tiprow

tiprow Bot commented May 14, 2026

Copy link
Copy Markdown

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

@ti-chi-bot
ti-chi-bot Bot merged commit 774d203 into pingcap:master May 14, 2026
38 checks passed
yongman pushed a commit to yongman/tidb that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. 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.

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

5 participants