Skip to content

Commit b7d4dfd

Browse files
authored
fix(resourcecontrol): prevent interface conversion panic in analyze request bypass check (#1777)
Signed-off-by: JmPotato <[email protected]>
1 parent 7793c67 commit b7d4dfd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/resourcecontrol/resource_control.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ func shouldBypass(req *tikvrpc.Request) bool {
6363
// Check both coprocessor request type and the request source to ensure the request is an internal analyze request.
6464
// Internal analyze request may consume a lot of resources, bypass it to avoid affecting the user experience.
6565
// This bypass currently only works with NextGen.
66-
if config.NextGen && (req.BatchCop().GetTp() == reqTypeAnalyze || req.Cop().GetTp() == reqTypeAnalyze) &&
67-
strings.Contains(requestSource, util.InternalTxnStats) {
68-
return true
66+
if config.NextGen && strings.Contains(requestSource, util.InternalTxnStats) {
67+
var tp int64
68+
switch req.Type {
69+
case tikvrpc.CmdBatchCop:
70+
tp = req.BatchCop().GetTp()
71+
case tikvrpc.CmdCop, tikvrpc.CmdCopStream:
72+
tp = req.Cop().GetTp()
73+
}
74+
if tp == reqTypeAnalyze {
75+
return true
76+
}
6977
}
7078
// Some internal requests should be bypassed, which may affect the user experience.
7179
// For example, the `alter user password` request completely bypasses resource control.

0 commit comments

Comments
 (0)