diff --git a/internal/resourcecontrol/resource_control.go b/internal/resourcecontrol/resource_control.go index 4a98ac2368..6bd67c5496 100644 --- a/internal/resourcecontrol/resource_control.go +++ b/internal/resourcecontrol/resource_control.go @@ -16,7 +16,6 @@ package resourcecontrol import ( "reflect" - "unsafe" "github.com/pingcap/kvproto/pkg/coprocessor" "github.com/pingcap/kvproto/pkg/kvrpcpb" @@ -43,9 +42,17 @@ func MakeRequestInfo(req *tikvrpc.Request) *RequestInfo { var writeBytes int64 switch r := req.Req.(type) { case *kvrpcpb.PrewriteRequest: - writeBytes += int64(r.TxnSize) + for _, m := range r.Mutations { + writeBytes += int64(len(m.Key)) + int64(len(m.Value)) + } + writeBytes += int64(len(r.PrimaryLock)) + for _, l := range r.Secondaries { + writeBytes += int64(len(l)) + } case *kvrpcpb.CommitRequest: - writeBytes += int64(unsafe.Sizeof(r.Keys)) + for _, k := range r.Keys { + writeBytes += int64(len(k)) + } } return &RequestInfo{writeBytes: writeBytes}