fix(resourcecontrol): prevent interface conversion panic in analyze request bypass check (#1777)

Signed-off-by: JmPotato <github@ipotato.me>
This commit is contained in:
JmPotato 2025-10-28 14:54:25 +08:00 committed by GitHub
parent 7793c676c4
commit b7d4dfd852
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 3 deletions

View File

@ -63,10 +63,18 @@ func shouldBypass(req *tikvrpc.Request) bool {
// Check both coprocessor request type and the request source to ensure the request is an internal analyze request. // Check both coprocessor request type and the request source to ensure the request is an internal analyze request.
// Internal analyze request may consume a lot of resources, bypass it to avoid affecting the user experience. // Internal analyze request may consume a lot of resources, bypass it to avoid affecting the user experience.
// This bypass currently only works with NextGen. // This bypass currently only works with NextGen.
if config.NextGen && (req.BatchCop().GetTp() == reqTypeAnalyze || req.Cop().GetTp() == reqTypeAnalyze) && if config.NextGen && strings.Contains(requestSource, util.InternalTxnStats) {
strings.Contains(requestSource, util.InternalTxnStats) { var tp int64
switch req.Type {
case tikvrpc.CmdBatchCop:
tp = req.BatchCop().GetTp()
case tikvrpc.CmdCop, tikvrpc.CmdCopStream:
tp = req.Cop().GetTp()
}
if tp == reqTypeAnalyze {
return true return true
} }
}
// Some internal requests should be bypassed, which may affect the user experience. // Some internal requests should be bypassed, which may affect the user experience.
// For example, the `alter user password` request completely bypasses resource control. // For example, the `alter user password` request completely bypasses resource control.
// Although it does not consume many resources, it can still impact the user experience. // Although it does not consume many resources, it can still impact the user experience.