Repository navigation
fix(cluster): CheckPrivileges looks up the replication user for ERR00007 (#2245) - #2302
Merged
svaroqui merged 1 commit intoNov 4, 2026
Conversation
…007 (#2245) Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Linked issue (required)
Fixes #2245
Summary
Problem: repman raises a blocking ERR00007 ("User must have REPLICATION SLAVE privilege on ...") for a replica even though the replication user has the grant and replication works.
How it happens:
db-servers-credential(monitor user) andreplication-credential(repl user) are different accounts, and the monitor user has no account matching a replica's address, for examplemonitor@'10.1.1.%'but a replica in10.2.2.0/24. Withmonitoring-check-grantson (the default path), the check asks the privileges of the monitor user for that replica, finds no match, and reports "N".repl@'10.2.2.%'is never looked at.Cause: in
ServerMonitor.CheckPrivileges(cluster/srv_chk.go), the loop under "Check replication user has correct privs" passedcluster.GetDbUser()todbhelper.GetPrivileges. The comment and the ERR00015 message both name the replication user.Fix: pass
cluster.GetRplUser(). One word. No other change, since the first check in the function (monitor user on the repman host) is meant to use the monitor user.Scope: I checked the other
GetPrivilegescall in the same function; it checks the monitor user for ERR00006/8/9 and is correct. If both credentials are the same user, nothing changes.How it was tested
New test
TestCheckPrivilegesLooksUpReplicationUserincluster/srv_chk_privileges_test.go, using sqlmock with the issue's layout (monitor account only for the repman host, repl account for10.2.2.%).mysql.userquery is asked for the monitor user so the expectedrepllookup is never made.Commands:
GOTOOLCHAIN=local go test ./cluster -run TestCheckPrivilegesLooksUpReplicationUser,gofmt -l.Not run: the full
clusterpackage (it crashes on develop with a concurrent map write, unrelated) and a real Docker regtest with MariaDB/MySQL.Checklist
Fixes #NNNN(orRefs #NNNNfor partial) — T9/T10develop(or a topology branch for failover/rejoin/split-brain changes) — T10/T20origin/developand checked no in-flight branch/PR already does this — T20doc/implementation/) updated — T8 (n/a, bug fix)