Skip to content

test PD follower fallback on stale regions#1980

Draft
okJiang wants to merge 1 commit into
tikv:masterfrom
okJiang:codex/pd-active-follower-fallback-test
Draft

test PD follower fallback on stale regions#1980
okJiang wants to merge 1 commit into
tikv:masterfrom
okJiang:codex/pd-active-follower-fallback-test

Conversation

@okJiang

@okJiang okJiang commented Jun 2, 2026

Copy link
Copy Markdown
Member

What changed

This PR adds a RegionCache unit test for active follower fallback when PD follower responses are stale or incomplete.

The test covers three region APIs:

  • GetRegion: the first follower-enabled request returns a stale pre-split region. The test verifies client-go rejects it as stale, retries without follower/router options, and gets the fresh leader result.
  • ScanRegions: the first follower-enabled request returns a stale region that cannot cover the requested range. The test verifies the gap path retries without follower/router options and gets the complete leader result.
  • BatchScanRegions: covers the same gap fallback behavior for batch scan.

Why

A normal successful request does not prove that active follower fallback worked. This regression test checks request options, retry counts, and final region IDs/ranges so the fallback path is explicitly exercised.

Tests

go test ./internal/locate -run '^TestRegionCache$/^TestRegionAPIFallbackFromStaleFollowerToLeader$' -count=1
go test ./internal/locate -count=1

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. labels Jun 2, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 2, 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 youjiali1995 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 Jun 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01e4310a-5221-4936-8a90-665d3a8d9a67

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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 and usage tips.

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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.

1 participant