-
Notifications
You must be signed in to change notification settings - Fork 6.2k
bootstrap: add cluster_id to the mysql.tidb table (#59511)
#65564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ti-chi-bot
merged 6 commits into
pingcap:release-8.5
from
ti-chi-bot:cherry-pick-59511-to-release-8.5
Mar 17, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7450065
This is an automated cherry-pick of #59511
YangKeao 8bd98c2
fix conflicts
YangKeao 8cad105
Merge remote-tracking branch 'origin/release-8.5' into cherry-pick-59…
YangKeao f88160a
fix test
YangKeao 84ae464
fix test
YangKeao f9e9b4b
Merge remote-tracking branch 'origin/release-8.5' into cherry-pick-59…
YangKeao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard the PD client before fetching
cluster_id.(*domain.Domain).GetPDClient()can returnnilwhen the store is notkv.StorageWithPD, so this dereference will panic during bootstrap/upgrade on uni-store/mock-store style deployments.🛠️ Suggested fix
// writeClusterID writes cluster id into mysql.tidb func writeClusterID(s sessiontypes.Session) { + pdClient := domain.GetDomain(s).GetPDClient() + if pdClient == nil { + logutil.BgLogger().Warn("skip writing cluster_id: PD client unavailable during bootstrap/upgrade") + return + } + ctx, cancel := context.WithTimeout(context.Background(), time.Duration(internalSQLTimeout)*time.Second) defer cancel() - clusterID := s.GetDomain().(*domain.Domain).GetPDClient().GetClusterID(ctx) + clusterID := pdClient.GetClusterID(ctx) mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, "TiDB Cluster ID.") ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`, mysql.SystemDB, mysql.TiDBTable,As per coding guidelines, "Keep error handling actionable and contextual; avoid silently swallowing errors in Go code".
🤖 Prompt for AI Agents