Skip to content

vars: validate some vars for tidb x#68196

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:masterfrom
ekexium:validate-tidbx-vars
May 14, 2026
Merged

vars: validate some vars for tidb x#68196
ti-chi-bot[bot] merged 3 commits into
pingcap:masterfrom
ekexium:validate-tidbx-vars

Conversation

@ekexium
Copy link
Copy Markdown
Member

@ekexium ekexium commented May 7, 2026

What problem does this PR solve?

Issue Number: close #60697

Problem Summary:

  • Disable pipelined dml and follower read in TiDB X

What changed and how does it work?

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.

Disallow non-leader tidb_replica_read. Disallow pipelined dml.

Summary by CodeRabbit

  • New Features

    • NextGen kernel mode now rejects non‑leader replica‑read modes and disallows the "bulk" DML type with validation errors.
  • Dependencies

    • TiKV client v2 dependency updated to a newer pseudo‑version.
  • Tests

    • Tests added and modified to validate NextGen behavior and to skip or gate scenarios unsupported in NextGen.

Review Change Stack

Signed-off-by: Ziqian Qin <eke@fastmail.com>
Copilot AI review requested due to automatic review settings May 7, 2026 07:47
@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label May 7, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented May 7, 2026

@ekexium 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: d735c0a8-e5b1-4488-b0c5-4de5ca072194

📥 Commits

Reviewing files that changed from the base of the PR and between 86bfa7b and d842606.

📒 Files selected for processing (3)
  • tests/realtikvtest/sessiontest/session_fail_test.go
  • tests/realtikvtest/txntest/replica_read_test.go
  • tests/realtikvtest/txntest/stale_read_test.go

📝 Walkthrough

Walkthrough

This PR bumps the tikv client-go/v2 dependency, adds Validation hooks to disallow non-leader TiDBReplicaRead modes and the bulk TiDBDMLType under the NextGen kernel, and updates tests and BUILD deps to gate or assert those restrictions.

Changes

NextGen Feature Restrictions

Layer / File(s) Summary
Dependency Update
DEPS.bzl, go.mod
Updated github.com/tikv/client-go/v2 pseudo-version and checksum (bump to ...-839228f8c022).
System Variable Validation
pkg/sessionctx/variable/sysvar.go
Added Validation hooks: disallow non-leader for TiDBReplicaRead and disallow bulk for TiDBDMLType when kerneltype.IsNextGen() is true.
NextGen Test Cases
pkg/sessionctx/variable/nextgen_test.go
Added TestTiDBDMLTypeInNextGen and TestTiDBReplicaReadInNextGen to assert acceptance/rejection and effective mappings in NextGen.
System Variable Tests
pkg/sessionctx/variable/sysvar_test.go
Updated TestTiDBReplicaRead to branch expectations on kerneltype.IsNextGen(): expect ErrNotSupportedInNextGen in NextGen, otherwise previous behavior.
Utility Tests
pkg/sessionctx/variable/varsutil_test.go
Updated TestVarsutil to conditionally assert NextGen rejection or validate internal v.replicaRead mappings in non-NextGen mode.
DistSQL Test Updates
pkg/executor/test/distsqltest/*, pkg/executor/distsql_test.go
Added //pkg/config/kerneltype dep and adjusted replicaReadModes / skipped TestAdaptiveClosestRead when in NextGen mode.
Executor Failpoint Tests
pkg/executor/executor_failpoint_test.go
Guarded stale-read explain/analyze assertions to run only when !kerneltype.IsNextGen().
Session & StaleRead Test Skips
pkg/session/test/variable/*, pkg/sessiontxn/*, pkg/sessiontxn/staleread/*, tests/realtikvtest/*
Added kerneltype imports/BUILD deps and t.Skip or gating to avoid running follower/closest replica-read scenarios in NextGen mode.

Sequence Diagram(s)

sequenceDiagram
  participant User as Client/API
  participant Sysvar as sysvar.TiDBReplicaRead/TiDBDMLType
  participant Kernel as kerneltype.IsNextGen
  User->>Sysvar: SET replica_read / SET dml_type
  Sysvar->>Kernel: IsNextGen()
  Kernel-->>Sysvar: true/false
  Sysvar-->>User: accept or ErrNotSupportedInNextGen
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

size/L, approved, lgtm

Suggested reviewers

  • nolouch
  • joechenrh

"🐰 I hopped through code with nimble cheer,
Leaders only now, no followers near,
Bulk DML tucked away, skipped by the test,
Builds and deps updated — we did our best,
A rabbit claps for rules kept clear."

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title 'vars: validate some vars for tidb x' is vague and uses generic terminology like 'some vars' that doesn't convey specific information about the changeset's main purpose. Provide a more specific title such as 'sessionctx,executor: disable follower replica read and bulk DML in TiDB X' to clearly indicate the main changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description includes the required issue reference and problem summary, marking unit tests as completed. However, 'What changed and how does it work?' section is empty, lacking technical details about implementation.
Linked Issues check ✅ Passed The PR addresses issue #60697 by validating and restricting follower replica read modes and bulk DML in next-gen environments through validation hooks and test gating, meeting the core objectives.
Out of Scope Changes check ✅ Passed All changes are scoped to disabling features incompatible with next-gen TiDB: validating replica read and DML settings, updating tests with NextGen kernel checks, and updating dependencies. No extraneous changes detected.

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

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds NextGen (TiDB X) restrictions to session/system variables so that features incompatible with the NextGen kernel cannot be enabled via sysvars, aligning runtime behavior with the NextGen feature set.

Changes:

  • Add NextGen-only validation for tidb_replica_read to reject any mode other than leader.
  • Add NextGen-only validation for tidb_dml_type to reject bulk mode.
  • Update and add unit tests (including //go:build nextgen coverage) to assert the new validation behavior.
  • Bump github.com/tikv/client-go/v2 dependency and Bazel DEPS.bzl metadata accordingly.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/sessionctx/variable/sysvar.go Adds NextGen validation hooks for tidb_replica_read and tidb_dml_type.
pkg/sessionctx/variable/varsutil_test.go Updates session var tests to expect NextGen validation failures for replica read follower/mixed modes.
pkg/sessionctx/variable/sysvar_test.go Updates sysvar validation test to branch on NextGen vs Classic behavior for tidb_replica_read.
pkg/sessionctx/variable/nextgen_test.go Adds NextGen-only tests verifying tidb_dml_type and tidb_replica_read are constrained as intended.
go.mod Bumps github.com/tikv/client-go/v2 pseudo-version.
go.sum Updates checksums for the bumped client-go version.
DEPS.bzl Updates Bazel go_repository strip_prefix/sha256/urls for the new client-go version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 80.64516% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.3211%. Comparing base (84d8269) to head (d842606).
⚠️ Report is 45 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68196        +/-   ##
================================================
- Coverage   77.7288%   76.3211%   -1.4077%     
================================================
  Files          1990       1992         +2     
  Lines        551970     566958     +14988     
================================================
+ Hits         429040     432709      +3669     
- Misses       122010     133496     +11486     
+ Partials        920        753       -167     
Flag Coverage Δ
integration 42.0460% <80.6451%> (+2.2441%) ⬆️

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

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

@ekexium ekexium requested a review from cfzjywxk May 7, 2026 08:15
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 7, 2026
@ekexium
Copy link
Copy Markdown
Member Author

ekexium commented May 11, 2026

/retest

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/executor/test/distsqltest/distsql_test.go (1)

133-140: ⚡ Quick win

Consider adding a comment explaining the next-gen restriction.

The conditional logic correctly restricts replica read modes when running on next-gen kernels, aligning with the PR objective. However, future maintainers would benefit from a brief comment explaining why non-leader modes are excluded for next-gen (e.g., "Next-gen TiKV does not support non-leader replica reads").

📝 Suggested comment
 	replicaReadModes := []string{
 		"leader",
 	}
+	// Next-gen kernel does not support non-leader replica read modes.
 	if !kerneltype.IsNextGen() {
 		replicaReadModes = append(replicaReadModes,
🤖 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/distsqltest/distsql_test.go` around lines 133 - 140, Add a
brief explanatory comment above the kerneltype.IsNextGen() conditional to
clarify why non-leader replica read modes are omitted for next-gen kernels
(e.g., that Next-gen TiKV does not support non-leader replica reads or that
replica reads are handled differently), so future maintainers understand the
restriction; locate the check using kerneltype.IsNextGen() and the
replicaReadModes slice to add the comment.
🤖 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.

Nitpick comments:
In `@pkg/executor/test/distsqltest/distsql_test.go`:
- Around line 133-140: Add a brief explanatory comment above the
kerneltype.IsNextGen() conditional to clarify why non-leader replica read modes
are omitted for next-gen kernels (e.g., that Next-gen TiKV does not support
non-leader replica reads or that replica reads are handled differently), so
future maintainers understand the restriction; locate the check using
kerneltype.IsNextGen() and the replicaReadModes slice to add the comment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fcb2f961-7d58-431a-8039-1ff36edc755a

📥 Commits

Reviewing files that changed from the base of the PR and between 3310e2e and 4cbed3c.

📒 Files selected for processing (1)
  • pkg/executor/test/distsqltest/distsql_test.go

@ekexium ekexium force-pushed the validate-tidbx-vars branch from 4cbed3c to f005b8d Compare May 11, 2026 11:38
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/executor/executor_failpoint_test.go (1)

810-818: 💤 Low value

Correct conditional gating for NextGen replica-read restrictions.

The stale-read test is correctly skipped on NextGen kernels where non-leader tidb_replica_read modes (like 'closest-replicas') are disabled per the PR objectives.

Consider adding a brief comment above line 810 explaining why this test is skipped on NextGen for future maintainability:

// Skip stale read with replica read test on NextGen where non-leader replica reads are disabled.
if !kerneltype.IsNextGen() {
🤖 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/executor_failpoint_test.go` around lines 810 - 818, Add a
one-line comment explaining why the stale-read replica test is skipped when
NextGen is enabled: place it immediately above the existing if
!kerneltype.IsNextGen() check in executor_failpoint_test.go, referencing that
NextGen disables non-leader replica reads (so modes like 'closest-replicas' are
not applicable). Keep the comment short and specific (e.g., "Skip stale read
with replica read test on NextGen where non-leader replica reads are
disabled."), leaving the surrounding code calling waitUntilReadTSSafe and the
explain/require assertions unchanged.
🤖 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.

Nitpick comments:
In `@pkg/executor/executor_failpoint_test.go`:
- Around line 810-818: Add a one-line comment explaining why the stale-read
replica test is skipped when NextGen is enabled: place it immediately above the
existing if !kerneltype.IsNextGen() check in executor_failpoint_test.go,
referencing that NextGen disables non-leader replica reads (so modes like
'closest-replicas' are not applicable). Keep the comment short and specific
(e.g., "Skip stale read with replica read test on NextGen where non-leader
replica reads are disabled."), leaving the surrounding code calling
waitUntilReadTSSafe and the explain/require assertions unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7e2adce6-3c60-4473-badf-d3318f23a554

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbed3c and f005b8d.

📒 Files selected for processing (6)
  • pkg/executor/distsql_test.go
  • pkg/executor/executor_failpoint_test.go
  • pkg/executor/test/distsqltest/distsql_test.go
  • pkg/session/test/variable/variable_test.go
  • pkg/sessiontxn/isolation/main_test.go
  • pkg/sessiontxn/staleread/provider_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/executor/test/distsqltest/distsql_test.go

Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ekexium ekexium force-pushed the validate-tidbx-vars branch from f005b8d to 86bfa7b Compare May 11, 2026 14:14
@ekexium
Copy link
Copy Markdown
Member Author

ekexium commented May 12, 2026

/retest

Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 12, 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 14, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 14, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-05-07 08:21:46.934461058 +0000 UTC m=+342379.807811050: ☑️ agreed by cfzjywxk.
  • 2026-05-14 04:07:47.001718209 +0000 UTC m=+325035.534497538: ☑️ agreed by zyguan.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, yudongusa, zyguan

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 the approved label May 14, 2026
@ti-chi-bot ti-chi-bot Bot merged commit bdd9783 into pingcap:master May 14, 2026
36 checks passed
@ekexium
Copy link
Copy Markdown
Member Author

ekexium commented May 14, 2026

/cherry-pick release-nextgen-20251011

@ti-chi-bot
Copy link
Copy Markdown
Member

@ekexium: new pull request created to branch release-nextgen-20251011: #68388.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-20251011

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 ti-community-infra/tichi repository.

@ekexium
Copy link
Copy Markdown
Member Author

ekexium commented May 18, 2026

/cherry-pick release-nextgen-202603

ti-chi-bot Bot pushed a commit that referenced this pull request May 18, 2026
@ti-chi-bot
Copy link
Copy Markdown
Member

@ekexium: new pull request created to branch release-nextgen-202603: #68458.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-202603

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 ti-community-infra/tichi repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable features that are not compatible with next-gen

6 participants