From c25bfdca69f9edf23e911217c47c3b484bc2c694 Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 22 Jan 2026 20:16:09 +0800 Subject: [PATCH] *: support tidb topru --- go-tipb/topsql_agent.pb.go | 1197 +++++++++++++++++++++++++++++++----- proto/topsql_agent.proto | 34 +- 2 files changed, 1093 insertions(+), 138 deletions(-) diff --git a/go-tipb/topsql_agent.pb.go b/go-tipb/topsql_agent.pb.go index 7b135c5e..16eacfbe 100644 --- a/go-tipb/topsql_agent.pb.go +++ b/go-tipb/topsql_agent.pb.go @@ -5,6 +5,7 @@ package tipb import ( "context" + encoding_binary "encoding/binary" "fmt" "io" "math" @@ -29,6 +30,37 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +type ReportInterval int32 + +const ( + ReportInterval_REPORT_INTERVAL_UNSPECIFIED ReportInterval = 0 + ReportInterval_REPORT_INTERVAL_15S ReportInterval = 15 + ReportInterval_REPORT_INTERVAL_30S ReportInterval = 30 + ReportInterval_REPORT_INTERVAL_60S ReportInterval = 60 +) + +var ReportInterval_name = map[int32]string{ + 0: "REPORT_INTERVAL_UNSPECIFIED", + 15: "REPORT_INTERVAL_15S", + 30: "REPORT_INTERVAL_30S", + 60: "REPORT_INTERVAL_60S", +} + +var ReportInterval_value = map[string]int32{ + "REPORT_INTERVAL_UNSPECIFIED": 0, + "REPORT_INTERVAL_15S": 15, + "REPORT_INTERVAL_30S": 30, + "REPORT_INTERVAL_60S": 60, +} + +func (x ReportInterval) String() string { + return proto.EnumName(ReportInterval_name, int32(x)) +} + +func (ReportInterval) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{0} +} + type TopSQLRecord struct { SqlDigest []byte `protobuf:"bytes,1,opt,name=sql_digest,json=sqlDigest,proto3" json:"sql_digest,omitempty"` PlanDigest []byte `protobuf:"bytes,2,opt,name=plan_digest,json=planDigest,proto3" json:"plan_digest,omitempty"` @@ -97,6 +129,152 @@ func (m *TopSQLRecord) GetKeyspaceName() []byte { return nil } +// TopRURecord represents RU statistics for a single (user, sql_digest, plan_digest) combination. +type TopRURecord struct { + KeyspaceName []byte `protobuf:"bytes,1,opt,name=keyspace_name,json=keyspaceName,proto3" json:"keyspace_name,omitempty"` + User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + SqlDigest []byte `protobuf:"bytes,3,opt,name=sql_digest,json=sqlDigest,proto3" json:"sql_digest,omitempty"` + PlanDigest []byte `protobuf:"bytes,4,opt,name=plan_digest,json=planDigest,proto3" json:"plan_digest,omitempty"` + Items []*TopRURecordItem `protobuf:"bytes,5,rep,name=items,proto3" json:"items,omitempty"` +} + +func (m *TopRURecord) Reset() { *m = TopRURecord{} } +func (m *TopRURecord) String() string { return proto.CompactTextString(m) } +func (*TopRURecord) ProtoMessage() {} +func (*TopRURecord) Descriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{1} +} +func (m *TopRURecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopRURecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopRURecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopRURecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopRURecord.Merge(m, src) +} +func (m *TopRURecord) XXX_Size() int { + return m.Size() +} +func (m *TopRURecord) XXX_DiscardUnknown() { + xxx_messageInfo_TopRURecord.DiscardUnknown(m) +} + +var xxx_messageInfo_TopRURecord proto.InternalMessageInfo + +func (m *TopRURecord) GetKeyspaceName() []byte { + if m != nil { + return m.KeyspaceName + } + return nil +} + +func (m *TopRURecord) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *TopRURecord) GetSqlDigest() []byte { + if m != nil { + return m.SqlDigest + } + return nil +} + +func (m *TopRURecord) GetPlanDigest() []byte { + if m != nil { + return m.PlanDigest + } + return nil +} + +func (m *TopRURecord) GetItems() []*TopRURecordItem { + if m != nil { + return m.Items + } + return nil +} + +// TopRURecordItem represents statistics within a single time bucket. +type TopRURecordItem struct { + TimestampSec uint64 `protobuf:"varint,1,opt,name=timestamp_sec,json=timestampSec,proto3" json:"timestamp_sec,omitempty"` + TotalRu float64 `protobuf:"fixed64,2,opt,name=total_ru,json=totalRu,proto3" json:"total_ru,omitempty"` + ExecCount uint64 `protobuf:"varint,3,opt,name=exec_count,json=execCount,proto3" json:"exec_count,omitempty"` + ExecDuration uint64 `protobuf:"varint,4,opt,name=exec_duration,json=execDuration,proto3" json:"exec_duration,omitempty"` +} + +func (m *TopRURecordItem) Reset() { *m = TopRURecordItem{} } +func (m *TopRURecordItem) String() string { return proto.CompactTextString(m) } +func (*TopRURecordItem) ProtoMessage() {} +func (*TopRURecordItem) Descriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{2} +} +func (m *TopRURecordItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopRURecordItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopRURecordItem.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopRURecordItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopRURecordItem.Merge(m, src) +} +func (m *TopRURecordItem) XXX_Size() int { + return m.Size() +} +func (m *TopRURecordItem) XXX_DiscardUnknown() { + xxx_messageInfo_TopRURecordItem.DiscardUnknown(m) +} + +var xxx_messageInfo_TopRURecordItem proto.InternalMessageInfo + +func (m *TopRURecordItem) GetTimestampSec() uint64 { + if m != nil { + return m.TimestampSec + } + return 0 +} + +func (m *TopRURecordItem) GetTotalRu() float64 { + if m != nil { + return m.TotalRu + } + return 0 +} + +func (m *TopRURecordItem) GetExecCount() uint64 { + if m != nil { + return m.ExecCount + } + return 0 +} + +func (m *TopRURecordItem) GetExecDuration() uint64 { + if m != nil { + return m.ExecDuration + } + return 0 +} + type TopSQLRecordItem struct { TimestampSec uint64 `protobuf:"varint,1,opt,name=timestamp_sec,json=timestampSec,proto3" json:"timestamp_sec,omitempty"` CpuTimeMs uint32 `protobuf:"varint,2,opt,name=cpu_time_ms,json=cpuTimeMs,proto3" json:"cpu_time_ms,omitempty"` @@ -112,7 +290,7 @@ func (m *TopSQLRecordItem) Reset() { *m = TopSQLRecordItem{} } func (m *TopSQLRecordItem) String() string { return proto.CompactTextString(m) } func (*TopSQLRecordItem) ProtoMessage() {} func (*TopSQLRecordItem) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{1} + return fileDescriptor_1b19f3a2fcd6965e, []int{3} } func (m *TopSQLRecordItem) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +390,7 @@ func (m *SQLMeta) Reset() { *m = SQLMeta{} } func (m *SQLMeta) String() string { return proto.CompactTextString(m) } func (*SQLMeta) ProtoMessage() {} func (*SQLMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{2} + return fileDescriptor_1b19f3a2fcd6965e, []int{4} } func (m *SQLMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -289,7 +467,7 @@ func (m *PlanMeta) Reset() { *m = PlanMeta{} } func (m *PlanMeta) String() string { return proto.CompactTextString(m) } func (*PlanMeta) ProtoMessage() {} func (*PlanMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{3} + return fileDescriptor_1b19f3a2fcd6965e, []int{5} } func (m *PlanMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -353,7 +531,7 @@ func (m *EmptyResponse) Reset() { *m = EmptyResponse{} } func (m *EmptyResponse) String() string { return proto.CompactTextString(m) } func (*EmptyResponse) ProtoMessage() {} func (*EmptyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{4} + return fileDescriptor_1b19f3a2fcd6965e, []int{6} } func (m *EmptyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,13 +561,17 @@ func (m *EmptyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_EmptyResponse proto.InternalMessageInfo type TopSQLSubRequest struct { + // enable_top_ru controls TopRU collection and reporting. + EnableTopRu bool `protobuf:"varint,1,opt,name=enable_top_ru,json=enableTopRu,proto3" json:"enable_top_ru,omitempty"` + // report_interval controls report interval, options: 15s/30s/60s. + ReportInterval ReportInterval `protobuf:"varint,2,opt,name=report_interval,json=reportInterval,proto3,enum=tipb.ReportInterval" json:"report_interval,omitempty"` } func (m *TopSQLSubRequest) Reset() { *m = TopSQLSubRequest{} } func (m *TopSQLSubRequest) String() string { return proto.CompactTextString(m) } func (*TopSQLSubRequest) ProtoMessage() {} func (*TopSQLSubRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{5} + return fileDescriptor_1b19f3a2fcd6965e, []int{7} } func (m *TopSQLSubRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -418,11 +600,26 @@ func (m *TopSQLSubRequest) XXX_DiscardUnknown() { var xxx_messageInfo_TopSQLSubRequest proto.InternalMessageInfo +func (m *TopSQLSubRequest) GetEnableTopRu() bool { + if m != nil { + return m.EnableTopRu + } + return false +} + +func (m *TopSQLSubRequest) GetReportInterval() ReportInterval { + if m != nil { + return m.ReportInterval + } + return ReportInterval_REPORT_INTERVAL_UNSPECIFIED +} + type TopSQLSubResponse struct { // Types that are valid to be assigned to RespOneof: // *TopSQLSubResponse_Record // *TopSQLSubResponse_SqlMeta // *TopSQLSubResponse_PlanMeta + // *TopSQLSubResponse_RuRecord RespOneof isTopSQLSubResponse_RespOneof `protobuf_oneof:"resp_oneof"` } @@ -430,7 +627,7 @@ func (m *TopSQLSubResponse) Reset() { *m = TopSQLSubResponse{} } func (m *TopSQLSubResponse) String() string { return proto.CompactTextString(m) } func (*TopSQLSubResponse) ProtoMessage() {} func (*TopSQLSubResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{6} + return fileDescriptor_1b19f3a2fcd6965e, []int{8} } func (m *TopSQLSubResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -474,10 +671,14 @@ type TopSQLSubResponse_SqlMeta struct { type TopSQLSubResponse_PlanMeta struct { PlanMeta *PlanMeta `protobuf:"bytes,3,opt,name=plan_meta,json=planMeta,proto3,oneof" json:"plan_meta,omitempty"` } +type TopSQLSubResponse_RuRecord struct { + RuRecord *TopRURecord `protobuf:"bytes,4,opt,name=ru_record,json=ruRecord,proto3,oneof" json:"ru_record,omitempty"` +} func (*TopSQLSubResponse_Record) isTopSQLSubResponse_RespOneof() {} func (*TopSQLSubResponse_SqlMeta) isTopSQLSubResponse_RespOneof() {} func (*TopSQLSubResponse_PlanMeta) isTopSQLSubResponse_RespOneof() {} +func (*TopSQLSubResponse_RuRecord) isTopSQLSubResponse_RespOneof() {} func (m *TopSQLSubResponse) GetRespOneof() isTopSQLSubResponse_RespOneof { if m != nil { @@ -507,17 +708,28 @@ func (m *TopSQLSubResponse) GetPlanMeta() *PlanMeta { return nil } +func (m *TopSQLSubResponse) GetRuRecord() *TopRURecord { + if x, ok := m.GetRespOneof().(*TopSQLSubResponse_RuRecord); ok { + return x.RuRecord + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*TopSQLSubResponse) XXX_OneofWrappers() []interface{} { return []interface{}{ (*TopSQLSubResponse_Record)(nil), (*TopSQLSubResponse_SqlMeta)(nil), (*TopSQLSubResponse_PlanMeta)(nil), + (*TopSQLSubResponse_RuRecord)(nil), } } func init() { + proto.RegisterEnum("tipb.ReportInterval", ReportInterval_name, ReportInterval_value) proto.RegisterType((*TopSQLRecord)(nil), "tipb.TopSQLRecord") + proto.RegisterType((*TopRURecord)(nil), "tipb.TopRURecord") + proto.RegisterType((*TopRURecordItem)(nil), "tipb.TopRURecordItem") proto.RegisterType((*TopSQLRecordItem)(nil), "tipb.TopSQLRecordItem") proto.RegisterMapType((map[string]uint64)(nil), "tipb.TopSQLRecordItem.StmtKvExecCountEntry") proto.RegisterType((*SQLMeta)(nil), "tipb.SQLMeta") @@ -530,58 +742,72 @@ func init() { func init() { proto.RegisterFile("topsql_agent.proto", fileDescriptor_1b19f3a2fcd6965e) } var fileDescriptor_1b19f3a2fcd6965e = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4d, 0x6f, 0x1b, 0x55, - 0x14, 0xf5, 0xd4, 0x4e, 0x62, 0x5f, 0xdb, 0x49, 0xfb, 0x92, 0xb4, 0x96, 0x25, 0x4c, 0x65, 0x04, - 0x44, 0x50, 0x5c, 0x70, 0x25, 0xa0, 0xac, 0xc0, 0x34, 0x52, 0x22, 0xda, 0x90, 0xbe, 0xe9, 0x82, - 0xdd, 0x68, 0x66, 0x7c, 0xb1, 0x46, 0x99, 0xf7, 0xe1, 0x79, 0x6f, 0x42, 0xcd, 0xaf, 0x60, 0xc9, - 0x82, 0x0d, 0x3b, 0xc4, 0x8e, 0x1f, 0x81, 0xc4, 0xb2, 0xcb, 0x2e, 0x51, 0x22, 0xf1, 0x3b, 0xd0, - 0xbb, 0x33, 0x4e, 0xc7, 0x49, 0xaa, 0x76, 0xf7, 0x7c, 0xee, 0x39, 0x67, 0xce, 0x7d, 0xf7, 0xce, - 0x18, 0x98, 0x55, 0xda, 0xcc, 0xd3, 0x20, 0x9c, 0xa1, 0xb4, 0x23, 0x9d, 0x29, 0xab, 0x58, 0xc3, - 0x26, 0x3a, 0xea, 0xef, 0xcc, 0xd4, 0x4c, 0x11, 0x70, 0xdf, 0x9d, 0x8a, 0x5a, 0x7f, 0x2b, 0xcb, - 0x8d, 0xa5, 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 0x90, 0xda, 0x9e, 0xc7, 0xbe, 0x80, 0x6e, 0xe1, 0xb1, 0xdc, 0xbe, 0xd5, 0xec, 0xaf, - 0x17, 0x3e, 0x84, 0xcd, 0x42, 0x78, 0xb1, 0x17, 0x97, 0x1a, 0x79, 0xad, 0x74, 0x7c, 0xbc, 0xfc, - 0xf0, 0x1e, 0xe7, 0x91, 0x9f, 0x47, 0xec, 0x6b, 0x68, 0xf9, 0x79, 0x64, 0xe2, 0x2c, 0x89, 0x90, - 0xad, 0x7c, 0x36, 0x5f, 0x4d, 0xaa, 0x7f, 0xe7, 0x0a, 0xbe, 0x74, 0xfc, 0xd4, 0x9b, 0x3c, 0x7c, - 0xf9, 0x47, 0xd3, 0xfb, 0xe7, 0x6c, 0xe0, 0xbd, 0x38, 0x1b, 0x78, 0xff, 0x9e, 0x0d, 0xbc, 0x5f, - 0xce, 0x07, 0xb5, 0x5f, 0xcf, 0x07, 0xb5, 0x17, 0xe7, 0x83, 0xda, 0xcb, 0xf3, 0x41, 0x0d, 0x76, - 0x63, 0x25, 0x46, 0x3a, 0x91, 0xb3, 0x38, 0xd4, 0x23, 0x9b, 0x4c, 0x23, 0xb2, 0x3b, 0xf6, 0xa2, - 0x75, 0xfa, 0x37, 0x78, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0xbf, 0x76, 0x3d, 0x50, - 0x06, 0x00, 0x00, + // 1038 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xc1, 0x6f, 0x1b, 0xc5, + 0x17, 0xf6, 0xc6, 0x4e, 0x62, 0x3f, 0xdb, 0xb1, 0x33, 0x49, 0x9a, 0xfc, 0xf2, 0x13, 0x6e, 0x65, + 0x04, 0x44, 0x6d, 0x71, 0x53, 0x47, 0x14, 0x8a, 0x40, 0x6a, 0xd3, 0x18, 0xc5, 0x22, 0x75, 0x9d, + 0xd9, 0x14, 0x71, 0x5b, 0xad, 0xd7, 0x43, 0xb4, 0xca, 0xee, 0xce, 0x7a, 0x67, 0x26, 0x10, 0xc4, + 0x9d, 0x2b, 0x17, 0x24, 0x0e, 0x5c, 0xb8, 0x71, 0x45, 0xfc, 0x13, 0x1c, 0x7b, 0xec, 0x81, 0x03, + 0x4a, 0x24, 0xfe, 0x0e, 0x34, 0x6f, 0x77, 0x5d, 0xdb, 0xeb, 0xa8, 0xb9, 0xed, 0x7e, 0xef, 0xfb, + 0xde, 0x7c, 0xef, 0xbd, 0x79, 0x5e, 0x03, 0x91, 0x3c, 0x14, 0x23, 0xcf, 0xb2, 0x4f, 0x59, 0x20, + 0x5b, 0x61, 0xc4, 0x25, 0x27, 0x05, 0xe9, 0x86, 0x83, 0xed, 0xf5, 0x53, 0x7e, 0xca, 0x11, 0x78, + 0xa0, 0x9f, 0xe2, 0xd8, 0x76, 0x2d, 0x52, 0x42, 0xe2, 0x63, 0x0c, 0x34, 0x7f, 0x33, 0xa0, 0x72, + 0xc2, 0x43, 0xf3, 0xf8, 0x88, 0x32, 0x87, 0x47, 0x43, 0xf2, 0x0e, 0x80, 0x4e, 0x38, 0x74, 0x4f, + 0x99, 0x90, 0x5b, 0xc6, 0x1d, 0x63, 0xa7, 0x42, 0x4b, 0x62, 0xe4, 0x1d, 0x20, 0x40, 0x6e, 0x43, + 0x39, 0xf4, 0xec, 0x20, 0x8d, 0x2f, 0x60, 0x1c, 0x34, 0x94, 0x10, 0xee, 0xc3, 0xa2, 0x2b, 0x99, + 0x2f, 0xb6, 0xf2, 0x77, 0xf2, 0x3b, 0xe5, 0xf6, 0xad, 0x96, 0x76, 0xd3, 0x9a, 0x3c, 0xa2, 0x2b, + 0x99, 0x4f, 0x63, 0x12, 0x79, 0x17, 0xaa, 0x67, 0xec, 0x42, 0x84, 0xb6, 0xc3, 0xac, 0xc0, 0xf6, + 0xd9, 0x56, 0x01, 0x13, 0x56, 0x52, 0xb0, 0x67, 0xfb, 0xac, 0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 0xc1, 0xd3, 0x8c, 0xbb, 0xc6, 0xfe, 0xe3, 0xd7, 0xbf, 0x17, 0x8d, 0xbf, 0x2e, + 0x1b, 0xc6, 0xab, 0xcb, 0x86, 0xf1, 0xcf, 0x65, 0xc3, 0xf8, 0xe9, 0xaa, 0x91, 0xfb, 0xe5, 0xaa, + 0x91, 0x7b, 0x75, 0xd5, 0xc8, 0xbd, 0xbe, 0x6a, 0xe4, 0x60, 0xc3, 0xe1, 0x7e, 0x2b, 0x74, 0x83, + 0x53, 0xc7, 0x0e, 0x5b, 0xd2, 0x1d, 0x0e, 0x30, 0x5d, 0xdf, 0x18, 0x2c, 0xe1, 0x1f, 0x96, 0xbd, + 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xb5, 0xff, 0xc2, 0xf3, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -604,6 +830,8 @@ type TopSQLAgentClient interface { // ReportPlanMeta reports plan meta to the agent. // The agent should deal with plan meta similarly to SQL meta. ReportPlanMeta(ctx context.Context, opts ...grpc.CallOption) (TopSQLAgent_ReportPlanMetaClient, error) + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + ReportTopRURecords(ctx context.Context, opts ...grpc.CallOption) (TopSQLAgent_ReportTopRURecordsClient, error) } type topSQLAgentClient struct { @@ -716,6 +944,40 @@ func (x *topSQLAgentReportPlanMetaClient) CloseAndRecv() (*EmptyResponse, error) return m, nil } +func (c *topSQLAgentClient) ReportTopRURecords(ctx context.Context, opts ...grpc.CallOption) (TopSQLAgent_ReportTopRURecordsClient, error) { + stream, err := c.cc.NewStream(ctx, &_TopSQLAgent_serviceDesc.Streams[3], "/tipb.TopSQLAgent/ReportTopRURecords", opts...) + if err != nil { + return nil, err + } + x := &topSQLAgentReportTopRURecordsClient{stream} + return x, nil +} + +type TopSQLAgent_ReportTopRURecordsClient interface { + Send(*TopRURecord) error + CloseAndRecv() (*EmptyResponse, error) + grpc.ClientStream +} + +type topSQLAgentReportTopRURecordsClient struct { + grpc.ClientStream +} + +func (x *topSQLAgentReportTopRURecordsClient) Send(m *TopRURecord) error { + return x.ClientStream.SendMsg(m) +} + +func (x *topSQLAgentReportTopRURecordsClient) CloseAndRecv() (*EmptyResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(EmptyResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // TopSQLAgentServer is the server API for TopSQLAgent service. type TopSQLAgentServer interface { // ReportTopSQLRecords is called periodically (e.g. per minute) to save the in-memory TopSQL records @@ -726,6 +988,8 @@ type TopSQLAgentServer interface { // ReportPlanMeta reports plan meta to the agent. // The agent should deal with plan meta similarly to SQL meta. ReportPlanMeta(TopSQLAgent_ReportPlanMetaServer) error + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + ReportTopRURecords(TopSQLAgent_ReportTopRURecordsServer) error } // UnimplementedTopSQLAgentServer can be embedded to have forward compatible implementations. @@ -741,6 +1005,9 @@ func (*UnimplementedTopSQLAgentServer) ReportSQLMeta(srv TopSQLAgent_ReportSQLMe func (*UnimplementedTopSQLAgentServer) ReportPlanMeta(srv TopSQLAgent_ReportPlanMetaServer) error { return status.Errorf(codes.Unimplemented, "method ReportPlanMeta not implemented") } +func (*UnimplementedTopSQLAgentServer) ReportTopRURecords(srv TopSQLAgent_ReportTopRURecordsServer) error { + return status.Errorf(codes.Unimplemented, "method ReportTopRURecords not implemented") +} func RegisterTopSQLAgentServer(s *grpc.Server, srv TopSQLAgentServer) { s.RegisterService(&_TopSQLAgent_serviceDesc, srv) @@ -824,6 +1091,32 @@ func (x *topSQLAgentReportPlanMetaServer) Recv() (*PlanMeta, error) { return m, nil } +func _TopSQLAgent_ReportTopRURecords_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TopSQLAgentServer).ReportTopRURecords(&topSQLAgentReportTopRURecordsServer{stream}) +} + +type TopSQLAgent_ReportTopRURecordsServer interface { + SendAndClose(*EmptyResponse) error + Recv() (*TopRURecord, error) + grpc.ServerStream +} + +type topSQLAgentReportTopRURecordsServer struct { + grpc.ServerStream +} + +func (x *topSQLAgentReportTopRURecordsServer) SendAndClose(m *EmptyResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *topSQLAgentReportTopRURecordsServer) Recv() (*TopRURecord, error) { + m := new(TopRURecord) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + var _TopSQLAgent_serviceDesc = grpc.ServiceDesc{ ServiceName: "tipb.TopSQLAgent", HandlerType: (*TopSQLAgentServer)(nil), @@ -844,6 +1137,11 @@ var _TopSQLAgent_serviceDesc = grpc.ServiceDesc{ Handler: _TopSQLAgent_ReportPlanMeta_Handler, ClientStreams: true, }, + { + StreamName: "ReportTopRURecords", + Handler: _TopSQLAgent_ReportTopRURecords_Handler, + ClientStreams: true, + }, }, Metadata: "topsql_agent.proto", } @@ -1009,7 +1307,7 @@ func (m *TopSQLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *TopSQLRecordItem) Marshal() (dAtA []byte, err error) { +func (m *TopRURecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1019,72 +1317,62 @@ func (m *TopSQLRecordItem) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *TopSQLRecordItem) MarshalTo(dAtA []byte) (int, error) { +func (m *TopRURecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TopSQLRecordItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TopRURecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.StmtNetworkOutBytes != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkOutBytes)) - i-- - dAtA[i] = 0x40 - } - if m.StmtNetworkInBytes != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkInBytes)) - i-- - dAtA[i] = 0x38 - } - if m.StmtDurationCount != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationCount)) - i-- - dAtA[i] = 0x30 - } - if m.StmtDurationSumNs != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationSumNs)) - i-- - dAtA[i] = 0x28 - } - if len(m.StmtKvExecCount) > 0 { - for k := range m.StmtKvExecCount { - v := m.StmtKvExecCount[k] - baseI := i - i = encodeVarintTopsqlAgent(dAtA, i, uint64(v)) - i-- - dAtA[i] = 0x10 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTopsqlAgent(dAtA, i, uint64(baseI-i)) + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopsqlAgent(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } - if m.StmtExecCount != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtExecCount)) + if len(m.PlanDigest) > 0 { + i -= len(m.PlanDigest) + copy(dAtA[i:], m.PlanDigest) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.PlanDigest))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x22 } - if m.CpuTimeMs != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.CpuTimeMs)) + if len(m.SqlDigest) > 0 { + i -= len(m.SqlDigest) + copy(dAtA[i:], m.SqlDigest) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.SqlDigest))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x1a } - if m.TimestampSec != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.TimestampSec)) + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.User))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x12 + } + if len(m.KeyspaceName) > 0 { + i -= len(m.KeyspaceName) + copy(dAtA[i:], m.KeyspaceName) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.KeyspaceName))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *SQLMeta) Marshal() (dAtA []byte, err error) { +func (m *TopRURecordItem) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1094,17 +1382,136 @@ func (m *SQLMeta) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SQLMeta) MarshalTo(dAtA []byte) (int, error) { +func (m *TopRURecordItem) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SQLMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TopRURecordItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.KeyspaceName) > 0 { + if m.ExecDuration != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.ExecDuration)) + i-- + dAtA[i] = 0x20 + } + if m.ExecCount != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.ExecCount)) + i-- + dAtA[i] = 0x18 + } + if m.TotalRu != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.TotalRu)))) + i-- + dAtA[i] = 0x11 + } + if m.TimestampSec != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.TimestampSec)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TopSQLRecordItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopSQLRecordItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopSQLRecordItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StmtNetworkOutBytes != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkOutBytes)) + i-- + dAtA[i] = 0x40 + } + if m.StmtNetworkInBytes != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkInBytes)) + i-- + dAtA[i] = 0x38 + } + if m.StmtDurationCount != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationCount)) + i-- + dAtA[i] = 0x30 + } + if m.StmtDurationSumNs != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationSumNs)) + i-- + dAtA[i] = 0x28 + } + if len(m.StmtKvExecCount) > 0 { + for k := range m.StmtKvExecCount { + v := m.StmtKvExecCount[k] + baseI := i + i = encodeVarintTopsqlAgent(dAtA, i, uint64(v)) + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintTopsqlAgent(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 + } + } + if m.StmtExecCount != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtExecCount)) + i-- + dAtA[i] = 0x18 + } + if m.CpuTimeMs != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.CpuTimeMs)) + i-- + dAtA[i] = 0x10 + } + if m.TimestampSec != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.TimestampSec)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SQLMeta) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SQLMeta) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SQLMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.KeyspaceName) > 0 { i -= len(m.KeyspaceName) copy(dAtA[i:], m.KeyspaceName) i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.KeyspaceName))) @@ -1232,6 +1639,21 @@ func (m *TopSQLSubRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ReportInterval != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.ReportInterval)) + i-- + dAtA[i] = 0x10 + } + if m.EnableTopRu { + i-- + if m.EnableTopRu { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -1330,6 +1752,27 @@ func (m *TopSQLSubResponse_PlanMeta) MarshalToSizedBuffer(dAtA []byte) (int, err } return len(dAtA) - i, nil } +func (m *TopSQLSubResponse_RuRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopSQLSubResponse_RuRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.RuRecord != nil { + { + size, err := m.RuRecord.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopsqlAgent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} func encodeVarintTopsqlAgent(dAtA []byte, offset int, v uint64) int { offset -= sovTopsqlAgent(v) base := offset @@ -1368,6 +1811,58 @@ func (m *TopSQLRecord) Size() (n int) { return n } +func (m *TopRURecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.KeyspaceName) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + l = len(m.User) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + l = len(m.SqlDigest) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + l = len(m.PlanDigest) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + } + return n +} + +func (m *TopRURecordItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TimestampSec != 0 { + n += 1 + sovTopsqlAgent(uint64(m.TimestampSec)) + } + if m.TotalRu != 0 { + n += 9 + } + if m.ExecCount != 0 { + n += 1 + sovTopsqlAgent(uint64(m.ExecCount)) + } + if m.ExecDuration != 0 { + n += 1 + sovTopsqlAgent(uint64(m.ExecDuration)) + } + return n +} + func (m *TopSQLRecordItem) Size() (n int) { if m == nil { return 0 @@ -1470,6 +1965,12 @@ func (m *TopSQLSubRequest) Size() (n int) { } var l int _ = l + if m.EnableTopRu { + n += 2 + } + if m.ReportInterval != 0 { + n += 1 + sovTopsqlAgent(uint64(m.ReportInterval)) + } return n } @@ -1519,16 +2020,214 @@ func (m *TopSQLSubResponse_PlanMeta) Size() (n int) { l = m.PlanMeta.Size() n += 1 + l + sovTopsqlAgent(uint64(l)) } - return n -} + return n +} +func (m *TopSQLSubResponse_RuRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RuRecord != nil { + l = m.RuRecord.Size() + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + return n +} + +func sovTopsqlAgent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTopsqlAgent(x uint64) (n int) { + return sovTopsqlAgent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopSQLRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopSQLRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SqlDigest", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SqlDigest = append(m.SqlDigest[:0], dAtA[iNdEx:postIndex]...) + if m.SqlDigest == nil { + m.SqlDigest = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanDigest", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PlanDigest = append(m.PlanDigest[:0], dAtA[iNdEx:postIndex]...) + if m.PlanDigest == nil { + m.PlanDigest = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, &TopSQLRecordItem{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyspaceName", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyspaceName = append(m.KeyspaceName[:0], dAtA[iNdEx:postIndex]...) + if m.KeyspaceName == nil { + m.KeyspaceName = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTopsqlAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func sovTopsqlAgent(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTopsqlAgent(x uint64) (n int) { - return sovTopsqlAgent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { +func (m *TopRURecord) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1551,13 +2250,79 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TopSQLRecord: wiretype end group for non-group") + return fmt.Errorf("proto: TopRURecord: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TopSQLRecord: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TopRURecord: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyspaceName", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyspaceName = append(m.KeyspaceName[:0], dAtA[iNdEx:postIndex]...) + if m.KeyspaceName == nil { + m.KeyspaceName = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SqlDigest", wireType) } @@ -1591,7 +2356,7 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { m.SqlDigest = []byte{} } iNdEx = postIndex - case 2: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PlanDigest", wireType) } @@ -1625,7 +2390,7 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { m.PlanDigest = []byte{} } iNdEx = postIndex - case 3: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) } @@ -1654,16 +2419,66 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Items = append(m.Items, &TopSQLRecordItem{}) + m.Items = append(m.Items, &TopRURecordItem{}) if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyspaceName", wireType) + default: + iNdEx = preIndex + skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) + if err != nil { + return err } - var byteLen int + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTopsqlAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TopRURecordItem) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopRURecordItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopRURecordItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimestampSec", wireType) + } + m.TimestampSec = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTopsqlAgent @@ -1673,26 +2488,60 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.TimestampSec |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTopsqlAgent - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTopsqlAgent + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalRu", wireType) } - if postIndex > l { + var v uint64 + if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.KeyspaceName = append(m.KeyspaceName[:0], dAtA[iNdEx:postIndex]...) - if m.KeyspaceName == nil { - m.KeyspaceName = []byte{} + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.TotalRu = float64(math.Float64frombits(v)) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecCount", wireType) + } + m.ExecCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecDuration", wireType) + } + m.ExecDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecDuration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) @@ -2441,6 +3290,45 @@ func (m *TopSQLSubRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: TopSQLSubRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableTopRu", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnableTopRu = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReportInterval", wireType) + } + m.ReportInterval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReportInterval |= ReportInterval(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) @@ -2596,6 +3484,41 @@ func (m *TopSQLSubResponse) Unmarshal(dAtA []byte) error { } m.RespOneof = &TopSQLSubResponse_PlanMeta{v} iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RuRecord", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &TopRURecord{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.RespOneof = &TopSQLSubResponse_RuRecord{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) diff --git a/proto/topsql_agent.proto b/proto/topsql_agent.proto index 96dd3711..1f863972 100644 --- a/proto/topsql_agent.proto +++ b/proto/topsql_agent.proto @@ -26,6 +26,8 @@ service TopSQLAgent { // ReportPlanMeta reports plan meta to the agent. // The agent should deal with plan meta similarly to SQL meta. rpc ReportPlanMeta(stream PlanMeta) returns (EmptyResponse) {} + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + rpc ReportTopRURecords(stream TopRURecord) returns (EmptyResponse) {} } message TopSQLRecord { @@ -35,6 +37,23 @@ message TopSQLRecord { bytes keyspace_name = 4; } +// TopRURecord represents RU statistics for a single (user, sql_digest, plan_digest) combination. +message TopRURecord { + bytes keyspace_name = 1; + string user = 2; + bytes sql_digest = 3; + bytes plan_digest = 4; + repeated TopRURecordItem items = 5; +} + +// TopRURecordItem represents statistics within a single time bucket. +message TopRURecordItem { + uint64 timestamp_sec = 1; // timestamp in second + double total_ru = 2; // cumulative RU consumption (RRU + WRU) + uint64 exec_count = 3; // execution count + uint64 exec_duration = 4; // cumulative execution time (nanoseconds) +} + message TopSQLRecordItem { uint64 timestamp_sec = 1; // timestamp in second uint32 cpu_time_ms = 2; // this value can be greater than 1000 when counting concurrent running SQL queries @@ -86,12 +105,25 @@ service TopSQLPubSub { rpc Subscribe(TopSQLSubRequest) returns (stream TopSQLSubResponse) {} } -message TopSQLSubRequest {} +enum ReportInterval { + REPORT_INTERVAL_UNSPECIFIED = 0; + REPORT_INTERVAL_15S = 15; + REPORT_INTERVAL_30S = 30; + REPORT_INTERVAL_60S = 60; +} + +message TopSQLSubRequest { + // enable_top_ru controls TopRU collection and reporting. + bool enable_top_ru = 1; + // report_interval controls report interval, options: 15s/30s/60s. + ReportInterval report_interval = 2; +} message TopSQLSubResponse { oneof resp_oneof { TopSQLRecord record = 1; SQLMeta sql_meta = 2; PlanMeta plan_meta = 3; + TopRURecord ru_record = 4; } }