Skip to content

executor: introduce max_user_connections#68965

Merged
ti-chi-bot[bot] merged 1 commit into
release-8.5from
bb7133/cp-6c7aaa0-release-8.5
Jun 12, 2026
Merged

executor: introduce max_user_connections#68965
ti-chi-bot[bot] merged 1 commit into
release-8.5from
bb7133/cp-6c7aaa0-release-8.5

Conversation

@bb7133

@bb7133 bb7133 commented Jun 4, 2026

Copy link
Copy Markdown
Member

This is an manual cherry-pick of #59197 to release-8.5 branch

What problem does this PR solve?

Issue Number: close #59203

Problem Summary:
TiDB supports max_user_connections to limit the number of user connections.

What changed and how does it work?

Conflict resolution for release-8.5

These are porting-only changes to resolve branch drift; they are not intended to change the original feature behavior beyond making the cherry-pick work correctly on the target release branch.

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.

TiDB supports max_user_connections to limit the login count.

Summary by CodeRabbit

  • New Features

    • Added global max_user_connections (0–100000) and per-user MAX_USER_CONNECTIONS; server enforces per-user limits and tracks active connections, returning a new "too many user connections" error.
  • Bug Fixes

    • Standardized too-many-connections error message; parser warnings now only appear when unsupported connection options other than MAX_USER_CONNECTIONS are used.
  • Migration

    • mysql.user schema and bootstrap advanced to store per-user max connections.
  • Tests

    • New and updated tests covering defaults, clamping, persistence, enforcement, identity tracking, and privilege checks.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/cherry-pick-not-approved do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

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: 42331309-5412-44ef-ae1f-2bca6e2d96f9

📥 Commits

Reviewing files that changed from the base of the PR and between 07183cb and fa93b4b.

📒 Files selected for processing (23)
  • br/pkg/restore/snap_client/systable_restore_test.go
  • errors.toml
  • pkg/errno/errname.go
  • pkg/executor/show.go
  • pkg/executor/simple.go
  • pkg/executor/test/simpletest/simple_test.go
  • pkg/parser/parser.go
  • pkg/parser/parser.y
  • pkg/privilege/privilege.go
  • pkg/privilege/privileges/cache.go
  • pkg/privilege/privileges/privileges.go
  • pkg/privilege/privileges/privileges_test.go
  • pkg/server/BUILD.bazel
  • pkg/server/conn.go
  • pkg/server/err/error.go
  • pkg/server/server.go
  • pkg/server/user_connections.go
  • pkg/server/user_connections_test.go
  • pkg/session/bootstrap.go
  • pkg/session/bootstrap_test.go
  • pkg/sessionctx/variable/noop.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/sessionctx/variable/tidb_vars.go
💤 Files with no reviewable changes (1)
  • pkg/sessionctx/variable/noop.go
✅ Files skipped from review due to trivial changes (3)
  • errors.toml
  • br/pkg/restore/snap_client/systable_restore_test.go
  • pkg/errno/errname.go
🚧 Files skipped from review as they are similar to previous changes (15)
  • pkg/server/BUILD.bazel
  • pkg/server/err/error.go
  • pkg/privilege/privilege.go
  • pkg/privilege/privileges/privileges.go
  • pkg/server/conn.go
  • pkg/parser/parser.y
  • pkg/executor/show.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/parser/parser.go
  • pkg/server/user_connections_test.go
  • pkg/privilege/privileges/cache.go
  • pkg/executor/simple.go
  • pkg/server/server.go
  • pkg/session/bootstrap.go
  • pkg/executor/test/simpletest/simple_test.go

📝 Walkthrough

Walkthrough

Adds global and per-user max_user_connections: sysvar and runtime value, bootstrap column + version bump to v231, parser and executor CREATE/ALTER/SHOW changes, privilege cache/API, server-side per-user counting/enforcement with a new error, and tests.

Changes

MAX_USER_CONNECTIONS resource limit implementation

Layer / File(s) Summary
Bootstrap schema and versioning
pkg/session/bootstrap.go, br/pkg/restore/snap_client/systable_restore_test.go, pkg/session/bootstrap_test.go
Adds Max_user_connections to mysql.user bootstrap DDL, introduces version231, bumps current bootstrap version to 231, adds upgradeToVer231, and updates tests and restore expectation/comments.
System variable and error infrastructure
pkg/sessionctx/variable/tidb_vars.go, pkg/sessionctx/variable/sysvar.go, pkg/sessionctx/variable/noop.go, errors.toml, pkg/errno/errname.go, pkg/server/err/error.go
Adds max_user_connections sysvar and atomic runtime value, removes noop registration, inserts [server:1203] error, updates MySQL error text, and exposes server error constant.
Parser support for MAX_USER_CONNECTIONS
pkg/parser/parser.go, pkg/parser/parser.y
With-connection-options warning is now conditional: MAX_USER_CONNECTIONS is allowed silently, and a TiDB warning is emitted only if other unsupported options are present.
Privilege cache and API
pkg/privilege/privilege.go, pkg/privilege/privileges/cache.go, pkg/privilege/privileges/privileges.go
Loads max_user_connections from mysql.user into privilege cache, adds Manager.GetUserResources to the interface, and adds methods to fetch per-user resources and encoded password after hash validation.
Executor CREATE/ALTER/SHOW USER handling
pkg/executor/simple.go, pkg/executor/show.go, pkg/executor/test/simpletest/simple_test.go
Introduces resourceOptionsInfo, parses/clamps MAX_USER_CONNECTIONS, persists it in mysql.user for CREATE USER, conditionally updates it in ALTER USER (requires CREATE USER privilege), and includes it in SHOW CREATE USER output when >0; adds TestMaxUserConnections.
Server bookkeeping and wiring
pkg/server/conn.go, pkg/server/server.go, pkg/server/BUILD.bazel
Adds countedUser to clientConn, userResource map and userResLock in Server, initializes bookkeeping, minor auth refactor, and registers new server sources in BUILD.
Server connection counting and enforcement
pkg/server/user_connections.go, pkg/server/server.go, pkg/server/user_connections_test.go
Implements calculateConnectionLimit, increaseUserConnectionsCount, decreaseUserConnectionCount, getUserConnectionCount, wires counting into onConn, returns [server:1203] when caps exceeded, and adds tests covering counting, enforcement, and identity tracking.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • pingcap/tidb#67337: Implements the same max_user_connections feature end-to-end with similar executor, server, and schema changes.

Suggested labels

cherry-pick-approved, type/cherry-pick-for-release-8.5, sig/sql-infra, ok-to-test, approved, lgtm

Suggested reviewers

  • winoros
  • terry1purcell
  • yudongusa

Poem

I'm a little rabbit with a counting hat,
Watching users hop and hop and chat.
Global caps and per-user ties,
I tally tails and keep watchful eyes.
Hop safe, small sockets—no overflow! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature being introduced: support for the max_user_connections limit.
Description check ✅ Passed The description comprehensively covers the problem statement, detailed changes, proper issue linking, test coverage, documentation impact, and a release note.
Linked Issues check ✅ Passed The PR implements the max_user_connections feature to limit per-user connections as required by issue #59203, with proper handling of global limits, per-user limits, and connection tracking.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing max_user_connections support across parser, privilege system, session management, and connection handling.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bb7133/cp-6c7aaa0-release-8.5

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)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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.

@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 (2)
pkg/executor/test/simpletest/simple_test.go (2)

271-273: ⚡ Quick win

Prefer error-code assertion over full parser message matching.

Line 273 asserts the complete parser message (including column offset/format), which is brittle. Assert parse error code instead.

Suggested change
-	_, err := tk.Exec(alterUserSQL)
-	require.Error(t, err)
-	require.Equal(t, err.Error(), "[parser:1064]You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 58 near \"-2;\" ")
+	tk.MustGetErrCode(alterUserSQL, mysql.ErrParse)

As per coding guidelines, test changes should stay minimal and deterministic.

🤖 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/simpletest/simple_test.go` around lines 271 - 273, The test
currently matches the entire parser message from tk.Exec(alterUserSQL) which is
brittle; replace the exact equality check (require.Equal(t, err.Error(), ...))
with an assertion that verifies the parse error code only (e.g., use
require.Contains(t, err.Error(), "[parser:1064]") or an equivalent error-code
check) while keeping require.Error(t, err) and using the same tk.Exec and
alterUserSQL variables so the test remains minimal and deterministic.

279-286: ⚡ Quick win

Add a SHOW CREATE USER assertion for the new resource clause.

This test verifies persistence in mysql.user, but it doesn’t yet validate the SQL-facing output contract (WITH MAX_USER_CONNECTIONS) added in executor show logic.

Suggested addition
 	alterUserSQL = `ALTER USER 'test2'@'localhost' WITH MAX_USER_CONNECTIONS 50000;`
 	tk.MustExec(alterUserSQL)
 	result = tk.MustQuery(`select user, max_user_connections from mysql.user WHERE User="test2"`)
 	result.Check(testkit.Rows("test2 50000"))
+	showRows := tk.MustQuery(`SHOW CREATE USER 'test2'@'localhost'`).Rows()
+	require.Contains(t, showRows[0][0].(string), "WITH MAX_USER_CONNECTIONS 50000")

Based on learnings, for SQL behavior changes in pkg/executor/**, perform targeted unit test plus relevant integration test.

🤖 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/simpletest/simple_test.go` around lines 279 - 286, Add
assertions that validate the SQL-facing output by running SHOW CREATE USER after
creating and altering the user and checking that the returned CREATE USER
statement contains the WITH MAX_USER_CONNECTIONS clause. Specifically, after
tk.MustExec(createUserSQL) and after tk.MustExec(alterUserSQL) call
tk.MustQuery("SHOW CREATE USER 'test2'@'localhost'") (or the testkit
equivalent), capture the result and use result.Check(...) to assert the returned
DDL string includes "WITH MAX_USER_CONNECTIONS 50000" so the executor's show
logic is verified alongside the mysql.user persistence checks.
🤖 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/privilege/privileges/privileges.go`:
- Around line 317-345: The new getters miss honoring the skip-grant fast-path;
modify GetEncodedPassword and GetUserResources to check
mysqlPriv.SkipWithGrant() after obtaining record :=
mysqlPriv.connectionVerification(user, host) and, when SkipWithGrant() is true,
return the record values directly (for GetEncodedPassword return
record.AuthenticationString or "" if record==nil; for GetUserResources return
record.MaxUserConnections, nil or 0,nil if record==nil) instead of performing
the normal isValidHash/error logic; otherwise keep the existing isValidHash
checks and error returns.

---

Nitpick comments:
In `@pkg/executor/test/simpletest/simple_test.go`:
- Around line 271-273: The test currently matches the entire parser message from
tk.Exec(alterUserSQL) which is brittle; replace the exact equality check
(require.Equal(t, err.Error(), ...)) with an assertion that verifies the parse
error code only (e.g., use require.Contains(t, err.Error(), "[parser:1064]") or
an equivalent error-code check) while keeping require.Error(t, err) and using
the same tk.Exec and alterUserSQL variables so the test remains minimal and
deterministic.
- Around line 279-286: Add assertions that validate the SQL-facing output by
running SHOW CREATE USER after creating and altering the user and checking that
the returned CREATE USER statement contains the WITH MAX_USER_CONNECTIONS
clause. Specifically, after tk.MustExec(createUserSQL) and after
tk.MustExec(alterUserSQL) call tk.MustQuery("SHOW CREATE USER
'test2'@'localhost'") (or the testkit equivalent), capture the result and use
result.Check(...) to assert the returned DDL string includes "WITH
MAX_USER_CONNECTIONS 50000" so the executor's show logic is verified alongside
the mysql.user persistence checks.
🪄 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: 75b2bdd9-6c8d-418b-8658-7276c16bd6d1

📥 Commits

Reviewing files that changed from the base of the PR and between 8323301 and ead0942.

📒 Files selected for processing (23)
  • br/pkg/restore/snap_client/systable_restore_test.go
  • errors.toml
  • pkg/errno/errname.go
  • pkg/executor/infoschema_reader_test.go
  • pkg/executor/show.go
  • pkg/executor/simple.go
  • pkg/executor/test/simpletest/simple_test.go
  • pkg/parser/parser.go
  • pkg/parser/parser.y
  • pkg/privilege/privilege.go
  • pkg/privilege/privileges/cache.go
  • pkg/privilege/privileges/privileges.go
  • pkg/server/BUILD.bazel
  • pkg/server/conn.go
  • pkg/server/err/error.go
  • pkg/server/server.go
  • pkg/server/user_connections.go
  • pkg/server/user_connections_test.go
  • pkg/session/bootstrap.go
  • pkg/session/bootstrap_test.go
  • pkg/sessionctx/variable/noop.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/sessionctx/variable/tidb_vars.go
💤 Files with no reviewable changes (1)
  • pkg/sessionctx/variable/noop.go

Comment thread pkg/privilege/privileges/privileges.go
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.02273% with 51 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@e420dda). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #68965   +/-   ##
================================================
  Coverage               ?   56.4254%           
================================================
  Files                  ?       1848           
  Lines                  ?     672980           
  Branches               ?          0           
================================================
  Hits                   ?     379732           
  Misses                 ?     265479           
  Partials               ?      27769           
Flag Coverage Δ
integration 39.9873% <46.5909%> (?)
unit 65.9273% <71.0227%> (?)

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

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

@bb7133 bb7133 force-pushed the bb7133/cp-6c7aaa0-release-8.5 branch 3 times, most recently from 949a4de to e37cb81 Compare June 4, 2026 23:55
@bb7133 bb7133 added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 4, 2026
@ti-chi-bot ti-chi-bot Bot removed the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 4, 2026
@bb7133 bb7133 added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 4, 2026
@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 4, 2026

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

🧹 Nitpick comments (1)
pkg/executor/test/simpletest/simple_test.go (1)

297-298: 💤 Low value

Prefer require.NoError for error assertions.

Using require.Nil(t, err) works but require.NoError(t, err) provides better diagnostic output when the assertion fails. The rest of this file uses require.NoError (e.g., line 292).

♻️ Suggested fix
 tk.MustExec(`GRANT CREATE USER ON *.* TO 'test1'@'localhost'`)
 _, err = tkTest1.Exec(`ALTER USER 'test1'@'localhost' WITH MAX_USER_CONNECTIONS 2`)
-require.Nil(t, err)
+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/executor/test/simpletest/simple_test.go` around lines 297 - 298, Replace
the require.Nil assertion with require.NoError for the tkTest1.Exec call: the
call to tkTest1.Exec(`ALTER USER 'test1'@'localhost' WITH MAX_USER_CONNECTIONS
2`) currently checks err with require.Nil(t, err) — change this to
require.NoError(t, err) to match the rest of the file and provide better
diagnostics.
🤖 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/simpletest/simple_test.go`:
- Around line 297-298: Replace the require.Nil assertion with require.NoError
for the tkTest1.Exec call: the call to tkTest1.Exec(`ALTER USER
'test1'@'localhost' WITH MAX_USER_CONNECTIONS 2`) currently checks err with
require.Nil(t, err) — change this to require.NoError(t, err) to match the rest
of the file and provide better diagnostics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fbdd3ba0-71a5-48a9-8d84-5cdf667eb25d

📥 Commits

Reviewing files that changed from the base of the PR and between 8402f9c and e37cb81.

📒 Files selected for processing (22)
  • br/pkg/restore/snap_client/systable_restore_test.go
  • errors.toml
  • pkg/errno/errname.go
  • pkg/executor/show.go
  • pkg/executor/simple.go
  • pkg/executor/test/simpletest/simple_test.go
  • pkg/parser/parser.go
  • pkg/parser/parser.y
  • pkg/privilege/privilege.go
  • pkg/privilege/privileges/cache.go
  • pkg/privilege/privileges/privileges.go
  • pkg/server/BUILD.bazel
  • pkg/server/conn.go
  • pkg/server/err/error.go
  • pkg/server/server.go
  • pkg/server/user_connections.go
  • pkg/server/user_connections_test.go
  • pkg/session/bootstrap.go
  • pkg/session/bootstrap_test.go
  • pkg/sessionctx/variable/noop.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/sessionctx/variable/tidb_vars.go
💤 Files with no reviewable changes (1)
  • pkg/sessionctx/variable/noop.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/server/BUILD.bazel
🚧 Files skipped from review as they are similar to previous changes (16)
  • pkg/server/err/error.go
  • pkg/parser/parser.go
  • errors.toml
  • pkg/executor/show.go
  • pkg/server/conn.go
  • pkg/privilege/privilege.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/privilege/privileges/cache.go
  • pkg/server/user_connections_test.go
  • pkg/sessionctx/variable/tidb_vars.go
  • pkg/session/bootstrap.go
  • pkg/session/bootstrap_test.go
  • pkg/privilege/privileges/privileges.go
  • pkg/parser/parser.y
  • pkg/server/server.go
  • pkg/server/user_connections.go

@bb7133

bb7133 commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

/test unit-test

@tiprow

tiprow Bot commented Jun 5, 2026

Copy link
Copy Markdown

@bb7133: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

/test fast_test_tiprow_for_release

Use /test all to run all jobs.

Details

In response to this:

/test unit-test

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.

@bb7133

bb7133 commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

/test unit-test

@tiprow

tiprow Bot commented Jun 5, 2026

Copy link
Copy Markdown

@bb7133: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

/test fast_test_tiprow_for_release

Use /test all to run all jobs.

Details

In response to this:

/test unit-test

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.

@bb7133 bb7133 force-pushed the bb7133/cp-6c7aaa0-release-8.5 branch from e37cb81 to 07183cb Compare June 10, 2026 20:59

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

🧹 Nitpick comments (2)
br/pkg/restore/snap_client/systable_restore_test.go (1)

57-59: 💤 Low value

Minor grammar fix: use singular verb.

"user table" is singular and should take "has" rather than "have".

📝 Proposed fix
-	// user table in cluster have more columns: still compatible, but should fall
+	// user table in cluster has more columns: still compatible, but should fall
 	// back to non-physical loading because direct physical loading can fail
 	// checksum validation when the backup snapshot lacks the new columns.
🤖 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 `@br/pkg/restore/snap_client/systable_restore_test.go` around lines 57 - 59,
Update the grammatical error in the comment that currently reads "user table in
cluster have more columns: still compatible..." to use the singular verb "has"
(i.e., "user table in cluster has more columns..."); locate the comment by
searching for the exact phrase "user table in cluster have more columns" in
systable_restore_test.go and replace "have" with "has".
pkg/executor/show.go (1)

1882-1886: 💤 Low value

Prefer GetUint64 for consistency with other UNSIGNED column handling.

Max_user_connections is defined as INT UNSIGNED in the schema. For consistency with how other unsigned columns like Password_reuse_history are read (line 1842 uses GetUint64), consider using:

maxUserConnections := rows[0].GetUint64(11)

Then adjust the comparison and formatting to use uint64. While the current implementation works (typical values are small and fit safely in int64), using the correct unsigned type improves consistency and future-proofs the code.

♻️ Proposed refactor
-	maxUserConnections := rows[0].GetInt64(11)
+	maxUserConnections := rows[0].GetUint64(11)
 	maxUserConnectionsStr := ""
 	if maxUserConnections > 0 {
 		maxUserConnectionsStr = fmt.Sprintf(" WITH MAX_USER_CONNECTIONS %d", maxUserConnections)
 	}
🤖 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/show.go` around lines 1882 - 1886, Replace the signed read with
an unsigned read: change rows[0].GetInt64(11) to rows[0].GetUint64(11) and make
maxUserConnections a uint64, then update the comparison (keep > 0 but applied to
uint64) and pass the uint64 into fmt.Sprintf when building the
maxUserConnectionsStr (ensure the format specifier matches the uint64 value).
This updates the use of maxUserConnections in the existing block that constructs
the " WITH MAX_USER_CONNECTIONS ..." string.
🤖 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 `@br/pkg/restore/snap_client/systable_restore_test.go`:
- Around line 57-59: Update the grammatical error in the comment that currently
reads "user table in cluster have more columns: still compatible..." to use the
singular verb "has" (i.e., "user table in cluster has more columns..."); locate
the comment by searching for the exact phrase "user table in cluster have more
columns" in systable_restore_test.go and replace "have" with "has".

In `@pkg/executor/show.go`:
- Around line 1882-1886: Replace the signed read with an unsigned read: change
rows[0].GetInt64(11) to rows[0].GetUint64(11) and make maxUserConnections a
uint64, then update the comparison (keep > 0 but applied to uint64) and pass the
uint64 into fmt.Sprintf when building the maxUserConnectionsStr (ensure the
format specifier matches the uint64 value). This updates the use of
maxUserConnections in the existing block that constructs the " WITH
MAX_USER_CONNECTIONS ..." string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ef35c035-f547-4606-976f-bb2c6026d9a4

📥 Commits

Reviewing files that changed from the base of the PR and between e37cb81 and 07183cb.

📒 Files selected for processing (22)
  • br/pkg/restore/snap_client/systable_restore_test.go
  • errors.toml
  • pkg/errno/errname.go
  • pkg/executor/show.go
  • pkg/executor/simple.go
  • pkg/executor/test/simpletest/simple_test.go
  • pkg/parser/parser.go
  • pkg/parser/parser.y
  • pkg/privilege/privilege.go
  • pkg/privilege/privileges/cache.go
  • pkg/privilege/privileges/privileges.go
  • pkg/server/BUILD.bazel
  • pkg/server/conn.go
  • pkg/server/err/error.go
  • pkg/server/server.go
  • pkg/server/user_connections.go
  • pkg/server/user_connections_test.go
  • pkg/session/bootstrap.go
  • pkg/session/bootstrap_test.go
  • pkg/sessionctx/variable/noop.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/sessionctx/variable/tidb_vars.go
💤 Files with no reviewable changes (14)
  • pkg/server/BUILD.bazel
  • pkg/sessionctx/variable/noop.go
  • pkg/privilege/privileges/cache.go
  • pkg/privilege/privilege.go
  • pkg/server/server.go
  • pkg/session/bootstrap_test.go
  • pkg/server/err/error.go
  • pkg/server/conn.go
  • pkg/sessionctx/variable/tidb_vars.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/server/user_connections_test.go
  • pkg/privilege/privileges/privileges.go
  • pkg/session/bootstrap.go
  • pkg/server/user_connections.go
✅ Files skipped from review due to trivial changes (1)
  • errors.toml
🚧 Files skipped from review as they are similar to previous changes (5)
  • pkg/errno/errname.go
  • pkg/parser/parser.y
  • pkg/parser/parser.go
  • pkg/executor/test/simpletest/simple_test.go
  • pkg/executor/simple.go

@bb7133 bb7133 force-pushed the bb7133/cp-6c7aaa0-release-8.5 branch from 07183cb to fa93b4b Compare June 10, 2026 21:34
@ti-chi-bot ti-chi-bot Bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jun 11, 2026
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 11, 2026
@ti-chi-bot ti-chi-bot Bot added the lgtm label Jun 11, 2026
@ti-chi-bot ti-chi-bot Bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 11, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-11 02:26:55.696703879 +0000 UTC m=+1013316.767021269: ☑️ agreed by D3Hunter.
  • 2026-06-11 02:32:08.23229812 +0000 UTC m=+1013629.302615510: ☑️ agreed by tiancaiamao.

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

Please open a document PR.

@ti-chi-bot

ti-chi-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, tangenta, tiancaiamao, yudongusa, YuJuncen

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 Jun 12, 2026
@ti-chi-bot ti-chi-bot Bot merged commit 5ae4c6c into release-8.5 Jun 12, 2026
31 of 37 checks passed
@ti-chi-bot ti-chi-bot Bot deleted the bb7133/cp-6c7aaa0-release-8.5 branch June 12, 2026 04:05
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants