Skip to content

vars: validate some vars for tidb x (#68196)#68388

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:release-nextgen-20251011from
ti-chi-bot:cherry-pick-68196-to-release-nextgen-20251011
May 18, 2026
Merged

vars: validate some vars for tidb x (#68196)#68388
ti-chi-bot[bot] merged 3 commits into
pingcap:release-nextgen-20251011from
ti-chi-bot:cherry-pick-68196-to-release-nextgen-20251011

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

@ti-chi-bot ti-chi-bot commented May 14, 2026

This is an automated cherry-pick of #68196

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

  • Chores

    • Updated KV protocol and client library dependencies to newer versions.
  • New Features

    • Added input validation for system variables in next-generation kernels: replica read now accepts only "leader" mode, and bulk DML type is unsupported.
  • Tests

    • Updated test suites to conditionally skip or adjust behavior based on next-generation kernel availability.

Review Change Stack

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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. type/cherry-pick-for-release-nextgen-20251011 labels May 14, 2026
@ti-chi-bot
Copy link
Copy Markdown
Member Author

@ekexium This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 14, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 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: a2995315-a7b6-4db3-be5e-63652bf0465c

📥 Commits

Reviewing files that changed from the base of the PR and between 7c944ca and e96123f.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • DEPS.bzl
  • go.mod
  • tests/realtikvtest/txntest/stale_read_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/realtikvtest/txntest/stale_read_test.go

📝 Walkthrough

Walkthrough

The PR gates NextGen-incompatible features by restricting TiDBReplicaRead to only the leader mode and blocking TiDBDMLType from accepting bulk operations when running on NextGen kernels. System variable validation functions enforce these restrictions with ErrNotSupportedInNextGen, while dozens of test files are updated to conditionally skip or gate replica-read and stale-read scenarios based on NextGen status. TiKV client dependencies are updated in DEPS.bzl and go.mod.

Changes

NextGen Compatibility Gating

Layer / File(s) Summary
System variable validation for NextGen
pkg/sessionctx/variable/sysvar.go
TiDBReplicaRead validation rejects all non-leader modes in NextGen and returns leader with ErrNotSupportedInNextGen; TiDBDMLType validation rejects bulk (case-insensitive) in NextGen.
NextGen test coverage for sysvars
pkg/sessionctx/variable/nextgen_test.go
New tests TestTiDBDMLTypeInNextGen and TestTiDBReplicaReadInNextGen validate allowed values (standard, leader) and rejected values (bulk, follower, closest-replicas) with expected error behavior.
Unit test assertions for sysvar validation
pkg/sessionctx/variable/sysvar_test.go, pkg/sessionctx/variable/varsutil_test.go
Existing sysvar tests branch on kerneltype.IsNextGen(): expect ErrNotSupportedInNextGen and default fallback values in NextGen, otherwise original behavior.
Executor test suite gating
pkg/executor/test/distsqltest/BUILD.bazel, pkg/executor/test/distsqltest/distsql_test.go, pkg/executor/distsql_test.go, pkg/executor/executor_failpoint_test.go
Distsqltest BUILD adds kerneltype dependency; replica-read mode enumeration conditionally appends non-leader modes only on non-NextGen; executor tests skip stale-read and adaptive-closest-read assertions on NextGen.
Session variable test gating
pkg/session/test/variable/BUILD.bazel, pkg/session/test/variable/variable_test.go
Session test BUILD adds kerneltype dependency; TestReplicaRead skips on NextGen with message indicating follower read is unsupported.
Isolation test configuration
pkg/sessiontxn/isolation/main_test.go
Test setup gates closest-replicas configuration to only apply when closetRead is enabled AND the build is not NextGen.
Stale-read integration test gating
tests/realtikvtest/txntest/stale_read_test.go
Multiple tests gate replica-read scenarios: TestTxnScopeAndValidateReadTs and TestStaleReadKVRequest skip replica-read checks; TestStaleReadKVRequest adjusts AS OF TIMESTAMP from NOW() to NOW() - INTERVAL 1 SECOND; TestStaleReadNoBackoff skips entirely; TestStaleReadAllCombinations conditionally appends non-leader modes.
Real TiKV test integration gates
tests/realtikvtest/sessiontest/session_fail_test.go, tests/realtikvtest/txntest/replica_read_test.go
Session and transaction tests gate stale-read and replica-read verification: TestTiKVClientReadTimeout wraps stale-read checks; TestReplicaReadEffectScope skips on NextGen.
Dependency version updates
DEPS.bzl, go.mod
github.com/pingcap/kvproto bumped to v0.0.0-20260513130714-a164c29a1dce; github.com/tikv/client-go/v2 updated to v2.0.8-0.20260514041053-e91097b8e3f9.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • pingcap/tidb#68196: Overlapping NextGen gating and TiDB X validations in pkg/sessionctx/variable/sysvar.go for TiDBReplicaRead and TiDBDMLType system variables with corresponding test coverage.

Suggested labels

size/XXL

Suggested reviewers

  • cfzjywxk
  • zyguan
  • yudongusa

Poem

🐰 NextGen brings a lighter load,
Fewer modes to test, the simpler road—
Just leader reads and standard DML,
Bulk and follower fare farewell,
Tests all skip with kerneltype's call,
A cleaner kernel, standing tall! ✨

🚥 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 generic, using non-descriptive terms that don't clearly convey the main purpose of disabling specific features. Revise the title to be more specific about the validation being performed, such as 'vars: validate replica read and DML type for next-gen kernels' or 'vars: disable unsupported replica read modes in next-gen'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required issue reference (#60697), problem summary, and release notes. However, it lacks detail about what specifically changed and how it works.
Linked Issues check ✅ Passed The PR addresses the linked issue #60697 by disabling pipelined DML and non-leader replica read modes in next-gen kernels through validation logic in system variable handlers.
Out of Scope Changes check ✅ Passed All changes are scoped to disabling unsupported features (pipelined DML and non-leader replica read) in next-gen kernels; dependency updates in DEPS.bzl and go.mod appear to be support changes for the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/realtikvtest/txntest/stale_read_test.go (1)

342-388: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Resolve merge-conflict markers in TestStaleReadKVRequest (lines 342–388).

The file contains unresolved conflict markers that make it invalid Go source, preventing compilation and test execution. Remove the conflict markers and choose the appropriate branch.

🤖 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 `@tests/realtikvtest/txntest/stale_read_test.go` around lines 342 - 388, The
file contains unresolved Git conflict markers inside TestStaleReadKVRequest
causing a compile error; remove the conflict markers (<<<<<<<, =======, >>>>>>>)
and reconcile the two variants: choose whether to keep the
kerneltype.IsNextGen() conditional block (which uses NOW() - INTERVAL 1 SECOND
and guards the three loops) or the original unconditional loops (which use
NOW()), then ensure the loops that enable/disable failpoints (using
failpoint.Enable/Disable), the START TRANSACTION / SET TRANSACTION statements,
and the final follower-read assertion loops (tk.MustQuery / tk.MustExec /
require.NoError) are consistent and compile; update only the conflicting section
so function TestStaleReadKVRequest and calls like tk.MustExec, tk.MustQuery,
failpoint.Enable/Disable remain valid and the file contains no conflict markers.
🧹 Nitpick comments (1)
pkg/sessionctx/variable/sysvar_test.go (1)

541-548: 💤 Low value

Minor: Reverse argument order for consistency.

Line 546 reverses the expected/actual order compared to line 544 and testify convention (require.Equal(t, expected, actual, ...)).

Style fix
 	} else {
-		require.Equal(t, val, "follower")
+		require.Equal(t, "follower", val)
 		require.NoError(t, err)
 	}
🤖 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/sessionctx/variable/sysvar_test.go` around lines 541 - 548, The test
asserts in the non-nextgen branch use the wrong argument order for testify's
require.Equal; change the call in the else branch so the expected value
"follower" is passed first and the actual val second (i.e., swap arguments in
the require.Equal call in the kerneltype.IsNextGen() else branch), keeping other
checks like require.Error/require.NoError and ErrNotSupportedInNextGen
comparisons 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.

Inline comments:
In `@DEPS.bzl`:
- Around line 7795-7811: Remove the Git merge conflict markers and keep the
incoming/cherry-picked client-go revision (the one with strip_prefix
"github.com/tikv/client-go/v2@v2.0.8-0.20260429090231-839228f8c022" and its
corresponding sha256
"239c5c831ab7ca4f27c0e2b3e73b2df5d828c38fb30ce2700c9d7f52b0ae4008") across the
affected files: update go.mod and go.sum to the incoming
v2.0.8-0.20260429090231-839228f8c022 entries, edit DEPS.bzl to remove the
<<<<<<</=======/>>>>>>> markers and keep the block with the 839228f8c022
strip_prefix/sha256/urls, and fix the two test files
(pkg/sessiontxn/staleread/provider_test.go and
tests/realtikvtest/txntest/stale_read_test.go) by removing conflict markers and
retaining the incoming changes from commit bdd978350e0; after edits run the
normal repo validation (go mod tidy && bazel/test commands) and then unhold per
ti-chi-bot.

In `@go.mod`:
- Around line 114-120: Resolve the unresolved merge markers by removing the
conflict blocks (the lines starting with <<<<<<<, =======, >>>>>>>) and keep
exactly one set of versions for the dependencies github.com/tikv/client-go/v2
and github.com/tikv/pd/client; choose the intended version pair (the one that
matches DEPS.bzl) and replace the conflicted block with those two clean
dependency lines so go.mod is valid and parses correctly.

In `@pkg/sessiontxn/staleread/provider_test.go`:
- Around line 88-89: Remove the unresolved Git merge conflict markers in
pkg/sessiontxn/staleread/provider_test.go (the sequences starting with <<<<<<<,
=======, and >>>>>>> at lines around 88–89 and 175) so the file is valid Go;
decide which of the conflicted blocks to keep (or merge their logic) and delete
the markers and the unwanted duplicate code, ensuring any referenced test
functions or helpers in provider_test.go remain correctly defined and the file
compiles.

---

Outside diff comments:
In `@tests/realtikvtest/txntest/stale_read_test.go`:
- Around line 342-388: The file contains unresolved Git conflict markers inside
TestStaleReadKVRequest causing a compile error; remove the conflict markers
(<<<<<<<, =======, >>>>>>>) and reconcile the two variants: choose whether to
keep the kerneltype.IsNextGen() conditional block (which uses NOW() - INTERVAL 1
SECOND and guards the three loops) or the original unconditional loops (which
use NOW()), then ensure the loops that enable/disable failpoints (using
failpoint.Enable/Disable), the START TRANSACTION / SET TRANSACTION statements,
and the final follower-read assertion loops (tk.MustQuery / tk.MustExec /
require.NoError) are consistent and compile; update only the conflicting section
so function TestStaleReadKVRequest and calls like tk.MustExec, tk.MustQuery,
failpoint.Enable/Disable remain valid and the file contains no conflict markers.

---

Nitpick comments:
In `@pkg/sessionctx/variable/sysvar_test.go`:
- Around line 541-548: The test asserts in the non-nextgen branch use the wrong
argument order for testify's require.Equal; change the call in the else branch
so the expected value "follower" is passed first and the actual val second
(i.e., swap arguments in the require.Equal call in the kerneltype.IsNextGen()
else branch), keeping other checks like require.Error/require.NoError and
ErrNotSupportedInNextGen comparisons unchanged.
🪄 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

Run ID: 39895c3b-d905-4db6-a7e2-159fa7b17b97

📥 Commits

Reviewing files that changed from the base of the PR and between 6c70927 and 7c944ca.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (18)
  • DEPS.bzl
  • go.mod
  • pkg/executor/distsql_test.go
  • pkg/executor/executor_failpoint_test.go
  • pkg/executor/test/distsqltest/BUILD.bazel
  • pkg/executor/test/distsqltest/distsql_test.go
  • pkg/session/test/variable/BUILD.bazel
  • pkg/session/test/variable/variable_test.go
  • pkg/sessionctx/variable/nextgen_test.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/sessionctx/variable/sysvar_test.go
  • pkg/sessionctx/variable/varsutil_test.go
  • pkg/sessiontxn/isolation/main_test.go
  • pkg/sessiontxn/staleread/BUILD.bazel
  • pkg/sessiontxn/staleread/provider_test.go
  • tests/realtikvtest/sessiontest/session_fail_test.go
  • tests/realtikvtest/txntest/replica_read_test.go
  • tests/realtikvtest/txntest/stale_read_test.go

Comment thread DEPS.bzl Outdated
Comment thread go.mod Outdated
Comment thread pkg/sessiontxn/staleread/provider_test.go Outdated
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 15, 2026
@ekexium ekexium force-pushed the cherry-pick-68196-to-release-nextgen-20251011 branch from dbacd64 to 053bf09 Compare May 15, 2026 08:03
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ekexium ekexium force-pushed the cherry-pick-68196-to-release-nextgen-20251011 branch from 053bf09 to e96123f Compare May 15, 2026 08:16
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 15, 2026
@ekexium ekexium requested review from cfzjywxk and zyguan May 15, 2026 08:16
@ekexium
Copy link
Copy Markdown
Member

ekexium commented May 15, 2026

/unhold

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 15, 2026
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label May 15, 2026
@ekexium
Copy link
Copy Markdown
Member

ekexium commented May 15, 2026

/retest

1 similar comment
@ekexium
Copy link
Copy Markdown
Member

ekexium commented May 15, 2026

/retest

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 37.03704% with 17 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-nextgen-20251011@6c70927). Learn more about missing BASE report.

Additional details and impacted files
@@                      Coverage Diff                      @@
##             release-nextgen-20251011     #68388   +/-   ##
=============================================================
  Coverage                            ?   71.8467%           
=============================================================
  Files                               ?       1835           
  Lines                               ?     493715           
  Branches                            ?          0           
=============================================================
  Hits                                ?     354718           
  Misses                              ?     115603           
  Partials                            ?      23394           
Flag Coverage Δ
unit 71.8467% <37.0370%> (?)

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

Components Coverage Δ
dumpling 56.3493% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 46.5810% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot ti-chi-bot Bot added cherry-pick-approved Cherry pick PR approved by release team. lgtm and removed do-not-merge/cherry-pick-not-approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 18, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 18, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-05-15 08:22:05.898251786 +0000 UTC m=+426694.431031115: ☑️ agreed by zyguan.
  • 2026-05-18 05:59:53.062657531 +0000 UTC m=+157522.566788217: ☑️ agreed by cfzjywxk.

Copy link
Copy Markdown

@yudongusa yudongusa left a comment

Choose a reason for hiding this comment

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

Please open a document PR

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 18, 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 18, 2026
@ti-chi-bot ti-chi-bot Bot merged commit bd3a668 into pingcap:release-nextgen-20251011 May 18, 2026
18 checks passed
@ti-chi-bot ti-chi-bot Bot deleted the cherry-pick-68196-to-release-nextgen-20251011 branch May 18, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. 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. type/cherry-pick-for-release-nextgen-20251011

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants