Skip to content

test: stabilize flaky TestTTLStatusCache/last_job_ttl_expire#69647

Open
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_e0e9af7a5fbf-a1
Open

test: stabilize flaky TestTTLStatusCache/last_job_ttl_expire#69647
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_e0e9af7a5fbf-a1

Conversation

@flaky-claw

@flaky-claw flaky-claw commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #69621

Problem Summary:
Flaky test TestTTLStatusCache/last_job_ttl_expire in pkg/ttl/cache intermittently fails, so this PR stabilizes that path.

What changed and how does it work?

Root Cause

TestTTLStatusCache assumed sibling subtests always ran before the selected subtest, so filtered/sharded execution made cumulative length assertions invalid.

Fix

Clearing the TTL status table per subtest makes each field-decoding check independent while preserving the exact decoded-field assertions.

Verification

Spec:

  • target: pkg/ttl/cache :: TestTTLStatusCache/last_job_ttl_expire
  • strategy: tidb.issue_scoped.v2
  • plan mode: BASELINE_ONLY
  • requirements: required case must execute; no skip; repeat count = 1
  • execution surface: GO_TEST_WITH_TAGS
  • build tags: intest, deadlock
  • baseline gates: required_flaky_gate, build_safety_gate, intent_guard_gate
  • feedback surface source: baseline_only

Observed result:

  • status: failed
  • required case executed: yes
  • submission decision: ALLOWED
  • note: Required flaky case executed during validation.
    Required flaky case was not skipped.
    target_flaky_validation passed.
    package_validation passed.

Gate checklist:

  • pre_fix_native_repro: SKIPPED
  • target_flaky_validation: PASS
  • package_validation: PASS
  • build_gate: BLOCKED
  • ready_lint: BLOCKED

Commands:

  • go test -json -tags=intest,deadlock ./pkg/ttl/cache -run '^TestTTLStatusCache/last_job_ttl_expire$' -count=1
  • go test -json -tags=intest,deadlock ./pkg/ttl/cache -count=1

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 #69621

Summary by CodeRabbit

  • Tests
    • Improved TTL cache test coverage by isolating each field case and verifying the cache contains a single expected entry after each update.
    • Added a safety check before validating cached table data, making the test more robust and easier to diagnose if it fails.

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 3, 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 yisaer 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

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

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: 4751c9ca-5902-4c01-a91f-7c2a4bad6c15

📥 Commits

Reviewing files that changed from the base of the PR and between 8be4bd0 and a890fef.

📒 Files selected for processing (1)
  • pkg/ttl/cache/ttlstatus_test.go

📝 Walkthrough

Walkthrough

The test TestTTLStatusCache was updated to clear the mysql.tidb_ttl_table_status table before each subtest's row insertion, then assert the cache contains exactly one entry with a nil-check before running field-specific assertions, replacing the previous cumulative index-based checks.

Changes

TTL status cache test fix

Layer / File(s) Summary
Clear table and assert single entry per subtest
pkg/ttl/cache/ttlstatus_test.go
Each subtest now clears the status table before inserting its row, asserts exactly one cache entry, and retrieves it into a nil-checked variable before the field assertion.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • pingcap/tidb#67243: Updates TTL status cache assertions by clearing/re-reading mysql.tidb_ttl_table_status entries in TestTTLStatusCache.

Suggested labels: ok-to-test, approved, lgtm

Suggested reviewers: lcwangchao, YangKeao

Poem

A hop, a clear, a fresh new row,
No stale old data left to grow.
One table found, checked nice and tight,
No more flaky tests at night.
🐇✨ Clean cache, delight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: stabilizing a flaky TTL cache test.
Description check ✅ Passed The description includes the issue link, problem summary, root cause, fix, verification, checklist, and release note.
Linked Issues check ✅ Passed The change addresses issue #69621 by making TestTTLStatusCache/last_job_ttl_expire independent and removing the flaky cumulative assumption.
Out of Scope Changes check ✅ Passed The PR only modifies the targeted test to fix flakiness and does not introduce unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.12.2)

level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: context deadline exceeded"
level=error msg="Timeout exceeded: try increasing it by passing --timeout option"


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.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.1091%. Comparing base (8be4bd0) to head (a890fef).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #69647        +/-   ##
================================================
- Coverage   76.3268%   74.1091%   -2.2178%     
================================================
  Files          2041       2050         +9     
  Lines        560589     576524     +15935     
================================================
- Hits         427880     427257       -623     
- Misses       131808     149060     +17252     
+ Partials        901        207       -694     
Flag Coverage Δ
integration 40.6921% <ø> (+0.9868%) ⬆️

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

Components Coverage Δ
dumpling 60.4471% <ø> (ø)
parser ∅ <ø> (∅)
br 47.4650% <ø> (-15.2563%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: TestTTLStatusCache/last_job_ttl_expire in pkg/ttl/cache

1 participant