-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: kill one's own connection doesn't require SUPER privilege #6954
Conversation
`kill tidb connID`, if the user is the owner of that connection, there is no need to check the SUPER privilege. SessionManager interface is slightly modified.
// If you have the SUPER privilege, you can kill all threads and statements. | ||
// Otherwise, you can kill only your own threads and statements. | ||
sm := b.ctx.GetSessionManager() | ||
if sm != nil { |
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.
Could the sm
be nil?
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.
In the test code
util/processinfo.go
Outdated
@@ -33,6 +33,6 @@ type ProcessInfo struct { | |||
// SessionManager is an interface for session manage. Show processlist and | |||
// kill statement rely on this interface. | |||
type SessionManager interface { | |||
ShowProcessList() []ProcessInfo | |||
ShowProcessList() map[uint64]ProcessInfo |
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.
Add comment for the return value.
// Otherwise, you can kill only your own threads and statements. | ||
sm := b.ctx.GetSessionManager() | ||
if sm != nil { | ||
processList := sm.ShowProcessList() |
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.
Could you add an interface for SessionManger like GetProcessByConnID(connID) ?
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.
GetProcessByConnID
make SessionManager
more complex.
GetProcessByConnID
can be implemented using ShowProcessList
which is already in SessionManager
I assume Kill
will not be too frequency so this choice would not hurt the performance.
@shenli
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.
So the interface ShowProcessList
returns a map instead of a list.
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.
Yes.
@tiancaiamao Please fix the CI. |
/run-all-tests |
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.
LGTM
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.
LGTM
/run-all-tests |
/run-all-tests |
…#6954) `kill tidb connID`, if the user is the owner of that connection, there is no need to check the SUPER privilege. SessionManager interface is slightly modified.
What have you changed? (mandatory)
kill tidb connID
, if the user is the owner of that connection, thereis no need to check the SUPER privilege.
SessionManager interface is slightly modified.
What are the type of the changes (mandatory)?
How has this PR been tested (mandatory)?
It's somehow difficult to test this change. I check it manually.
PTAL @jackysp