Skip to content

test: stabilize flaky TestFlashbackClusterWithManyDBs#70057

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

test: stabilize flaky TestFlashbackClusterWithManyDBs#70057
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_d392b65bd2fa-a2

Conversation

@flaky-claw

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

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #68328

Problem Summary:
Flaky test TestFlashbackClusterWithManyDBs in pkg/executor/test/recovertest intermittently fails, so this PR stabilizes that path.

What changed and how does it work?

Root Cause

TestFlashbackClusterWithManyDBs relied on failpoint-only flashback bypasses while raw validation used the real non-TiKV guard.

Fix

A mock TiKV-shaped store preserves the flashback-cluster DDL path and removes the target test’s failpoint harness dependency.

Verification

Spec:

  • target: pkg/executor/test/recovertest :: TestFlashbackClusterWithManyDBs
  • strategy: tidb.go_flaky.default
  • 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_acceptance passed.
    build passed.
    ready_lint passed.

Gate checklist:

  • native_prefixed_target: SKIPPED
  • target_acceptance: PASS
  • package_raw_diagnostic: SKIPPED
  • build: PASS
  • ready_lint: PASS
  • bazel_prepare: FAIL

Commands:

  • go test -json -tags=intest,deadlock ./pkg/executor/test/recovertest -run '^TestFlashbackClusterWithManyDBs$' -count=1
  • make build
  • make lint
  • make bazel_prepare

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

Summary by CodeRabbit

  • Tests
    • Improved flashback-cluster test coverage across multiple databases.
    • Added more realistic TiKV mock behavior and controllable safe-timestamp handling.
    • Enhanced test setup and cleanup for sessions, statistics, storage, and resource management.
    • Updated test dependencies to support the expanded infrastructure.

@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Jul 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 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 csuzhangxc 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The recovery test now constructs a TiKV-mocked flashback cluster with atomic safe-timestamp control, session and resource-manager setup, RPC interception, and explicit cleanup. Bazel dependencies and test imports were updated accordingly.

Changes

Flashback cluster test stabilization

Layer / File(s) Summary
Test scaffolding and dependencies
pkg/executor/test/recovertest/BUILD.bazel, pkg/executor/test/recovertest/recover_test.go
Adds internal and external dependencies plus imports for session setup, resource management, TiKV RPC handling, atomic state, and lifecycle management.
Mock store and safe timestamp integration
pkg/executor/test/recovertest/recover_test.go
Adds TiKV client interception, a wrapped mock store with atomic minSafeTS, session bootstrapping, cleanup hooks, and direct safe-timestamp assignment in TestFlashbackClusterWithManyDBs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

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

Suggested reviewers: lcwangchao

Poem

A rabbit hops through flashback time,
With mock TiKV bells that chime.
Safe timestamps softly stay,
While flaky ghosts are sent away.
Cleanup closes the scene—
Recovery runs serene.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR’s main change: stabilizing flaky TestFlashbackClusterWithManyDBs.
Description check ✅ Passed It follows the template and includes the issue, problem summary, change details, tests, side effects, and release note.
Linked Issues check ✅ Passed The changes address #68328 by stabilizing TestFlashbackClusterWithManyDBs, matching the linked issue’s goal.
Out of Scope Changes check ✅ Passed The added Bazel deps and test harness changes support the flaky test fix and do not introduce unrelated scope.
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

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.

@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

🧹 Nitpick comments (1)
pkg/executor/test/recovertest/recover_test.go (1)

748-793: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Restore the schema lease after the test instead of leaving it mutated globally.

vardef.SetSchemaLease(500 * time.Millisecond) at line 778 permanently overwrites the global schema lease with no backup/restore, unlike the kv.TxnEntrySizeLimit backup pattern used a few lines later in TestFlashbackClusterWithManyDBs (Lines 814-818: save old value, t.Cleanup restores it). Since this is a global package-level setting, it can leak into other tests executed later in the same test binary/package, undermining the test-isolation goal of this flakiness fix.

🔧 Proposed fix
+	prevLease := vardef.SchemaLease.Load()
 	vardef.SetSchemaLease(500 * time.Millisecond)
 	session.DisableStats4Test()
 	domain.DisablePlanReplayerBackgroundJob4Test()
 	domain.DisableDumpHistoricalStats4Test()
 	dom, err := session.BootstrapSession(wrappedStore)
 	require.NoError(t, err)
 	dom.SetStatsUpdating(true)
 	t.Cleanup(func() {
 		dom.Close()
 		view.Stop()
 		require.NoError(t, wrappedStore.Close())
 		resourcemanager.InstanceResourceManager.Reset()
+		vardef.SetSchemaLease(prevLease)
 	})

(Adjust the getter to whatever accessor vardef exposes for the current lease value.)

As per coding guidelines, "Go code: Follow existing package-local conventions first and keep style consistent with nearby files."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/executor/test/recovertest/recover_test.go` around lines 748 - 793, Update
newFlashbackClusterTestStore to capture the current vardef schema lease before
calling vardef.SetSchemaLease, then register a t.Cleanup callback that restores
the captured value. Keep the 500-millisecond lease during the test and follow
the existing backup/restore pattern used by TestFlashbackClusterWithManyDBs,
using vardef’s available getter.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/executor/test/recovertest/BUILD.bazel`:
- Around line 15-16: Reorder the deps entries in the test target’s BUILD
definition so //pkg/ddl/util appears before //pkg/domain, preserving Gazelle’s
lexical alphabetical ordering and leaving all other dependencies unchanged.

---

Nitpick comments:
In `@pkg/executor/test/recovertest/recover_test.go`:
- Around line 748-793: Update newFlashbackClusterTestStore to capture the
current vardef schema lease before calling vardef.SetSchemaLease, then register
a t.Cleanup callback that restores the captured value. Keep the 500-millisecond
lease during the test and follow the existing backup/restore pattern used by
TestFlashbackClusterWithManyDBs, using vardef’s available getter.
🪄 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 Plus

Run ID: 3d5a193c-7822-4236-8be2-da23da0c7db8

📥 Commits

Reviewing files that changed from the base of the PR and between 231dad5 and aa0178f.

📒 Files selected for processing (2)
  • pkg/executor/test/recovertest/BUILD.bazel
  • pkg/executor/test/recovertest/recover_test.go

Comment on lines +15 to 16
"//pkg/domain",
"//pkg/ddl/util",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Dep list out of alphabetical order — likely cause of the bazel_prepare failure.

//pkg/domain (line 15) is listed before //pkg/ddl/util (line 16), but "ddl" sorts before "domain" lexically. Gazelle-generated deps lists are alphabetically sorted, and the PR description notes bazel_prepare failed — this ordering mismatch is a likely culprit.

🔧 Proposed fix
         "//pkg/config",
         "//pkg/config/kerneltype",
-        "//pkg/domain",
         "//pkg/ddl/util",
+        "//pkg/domain",
         "//pkg/errno",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"//pkg/domain",
"//pkg/ddl/util",
"//pkg/ddl/util",
"//pkg/domain",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/executor/test/recovertest/BUILD.bazel` around lines 15 - 16, Reorder the
deps entries in the test target’s BUILD definition so //pkg/ddl/util appears
before //pkg/domain, preserving Gazelle’s lexical alphabetical ordering and
leaving all other dependencies unchanged.

@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

@flaky-claw: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-unit-test-next-gen aa0178f link true /test pull-unit-test-next-gen

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.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #70057        +/-   ##
================================================
- Coverage   76.3266%   73.9381%   -2.3885%     
================================================
  Files          2041       2058        +17     
  Lines        559579     578881     +19302     
================================================
+ Hits         427108     428014       +906     
- Misses       131570     150512     +18942     
+ Partials        901        355       -546     
Flag Coverage Δ
integration 40.9431% <ø> (+1.2379%) ⬆️

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

Components Coverage Δ
dumpling 59.8807% <ø> (ø)
parser ∅ <ø> (∅)
br 47.4060% <ø> (-15.3154%) ⬇️
🚀 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: TestFlashbackClusterWithManyDBs in pkg/executor/test/recovertest

1 participant