Skip to content

br/pkg/streamhelper: stabilize flaky TestStoreRemoved#67954

Merged
ti-chi-bot[bot] merged 1 commit intopingcap:masterfrom
flaky-claw:flakyfixer/case_d58a9ddcd208-a7
Apr 24, 2026
Merged

br/pkg/streamhelper: stabilize flaky TestStoreRemoved#67954
ti-chi-bot[bot] merged 1 commit intopingcap:masterfrom
flaky-claw:flakyfixer/case_d58a9ddcd208-a7

Conversation

@flaky-claw
Copy link
Copy Markdown
Contributor

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

What problem does this PR solve?

Issue Number: close #52791

Problem Summary:
Flaky test TestStoreRemoved in br/pkg/streamhelper intermittently fails, so this PR stabilizes that path.

What changed and how does it work?

Root Cause

TestStoreRemoved was flaky because it used channel-idle timing (waitPendingEvents) as a proxy for delivery completion, so post-removal events could still be in flight when Drop() canceled them.

Fix

The test needed to wait for the semantic condition it actually cares about, namely that the subscriber has observed full-span coverage at the final post-removal checkpoint.

Verification

Spec:

  • target: br/pkg/streamhelper :: TestStoreRemoved
  • 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 ./br/pkg/streamhelper -run '^TestStoreRemoved$' -count=1
  • go test -json ./br/pkg/streamhelper -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 #52791

Summary by CodeRabbit

  • Tests
    • Improved test utility by consolidating span collection and synchronization logic into a reusable helper function, reducing code duplication and enhancing test maintainability.

@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 22, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Apr 22, 2026

@flaky-claw I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ 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 22, 2026
@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 22, 2026

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
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

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: 7777c681-f26e-4b71-8065-e99f75a1c3bb

📥 Commits

Reviewing files that changed from the base of the PR and between 874ff37 and 7243d5e.

📒 Files selected for processing (1)
  • br/pkg/streamhelper/subscription_test.go

📝 Walkthrough

Walkthrough

Added a helper function collectCheckpointSpans to consolidate event synchronization and span collection logic in a test. Updated TestStoreRemoved to use this helper instead of manually waiting and draining events, reducing code duplication and improving reliability of the flaky test.

Changes

Cohort / File(s) Summary
Test Synchronization Helper
br/pkg/streamhelper/subscription_test.go
Introduced collectCheckpointSpans helper to wait for events until a checkpoint is reached, then merged into span collection. Refactored TestStoreRemoved to use the new helper, eliminating separate waitPendingEvents and manual event drain loop.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

contribution, size/XS, ok-to-test, approved, lgtm

Suggested reviewers

  • YuJuncen
  • Leavrth

Poem

🐰 A flaky test once made us frown,
But now a helper saves the crown!
Events synchronized with grace,
No more race conditions in this place. ✨

🚥 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
Title check ✅ Passed The title clearly and specifically describes the main change: stabilizing a flaky test in the br/pkg/streamhelper package.
Description check ✅ Passed The PR description follows the template structure with required sections: issue number, problem summary, what changed and how, verification details, and test checklist completed.
Linked Issues check ✅ Passed The PR addresses issue #52791 by replacing timing-based synchronization with semantic condition checking to eliminate test flakiness, directly meeting the objective.
Out of Scope Changes check ✅ Passed All changes are within scope: a new test helper and modifications to TestStoreRemoved to stabilize the flaky test in br/pkg/streamhelper.

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

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

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 23, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 24, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth, YuJuncen

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

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 24, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 24, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-23 04:18:59.90721965 +0000 UTC m=+2225945.112579707: ☑️ agreed by YuJuncen.
  • 2026-04-24 02:00:32.625691802 +0000 UTC m=+2304037.831051859: ☑️ agreed by Leavrth.

@yinsustart
Copy link
Copy Markdown

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 24, 2026

@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

/check-issue-triage-complete

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.1620%. Comparing base (874ff37) to head (7243d5e).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67954        +/-   ##
================================================
+ Coverage   77.7953%   78.1620%   +0.3666%     
================================================
  Files          1984       1992         +8     
  Lines        549728     556091      +6363     
================================================
+ Hits         427663     434652      +6989     
+ Misses       121145     120027      -1118     
- Partials        920       1412       +492     
Flag Coverage Δ
integration 44.8377% <ø> (+5.0404%) ⬆️

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

Components Coverage Δ
dumpling 60.4888% <ø> (ø)
parser ∅ <ø> (∅)
br 65.9359% <ø> (+2.9054%) ⬆️
🚀 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.

@ti-chi-bot ti-chi-bot Bot merged commit 25fa27a into pingcap:master Apr 24, 2026
40 of 44 checks passed
premal pushed a commit to premal/tidb that referenced this pull request Apr 30, 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/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 TestStoreRemoved

4 participants