From be7f3b76b1bdb7f36441e5138bc643821b1974a2 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Wed, 10 Jul 2024 16:31:01 +0530 Subject: [PATCH 1/9] proto: added unresolved distributed transaction signal to health stream Signed-off-by: Harshit Gangal --- go/vt/proto/query/query.pb.go | 308 +++++++++++++------------- go/vt/proto/query/query_vtproto.pb.go | 34 +++ proto/query.proto | 2 + web/vtadmin/src/proto/vtadmin.d.ts | 6 + web/vtadmin/src/proto/vtadmin.js | 23 ++ 5 files changed, 224 insertions(+), 149 deletions(-) diff --git a/go/vt/proto/query/query.pb.go b/go/vt/proto/query/query.pb.go index 7723797f895..dd88e67af22 100644 --- a/go/vt/proto/query/query.pb.go +++ b/go/vt/proto/query/query.pb.go @@ -5182,7 +5182,8 @@ type RealtimeStats struct { // view_schema_changed is to provide list of views that have schema changes detected by the tablet. ViewSchemaChanged []string `protobuf:"bytes,8,rep,name=view_schema_changed,json=viewSchemaChanged,proto3" json:"view_schema_changed,omitempty"` // udfs_changed is used to signal that the UDFs have changed on the tablet. - UdfsChanged bool `protobuf:"varint,9,opt,name=udfs_changed,json=udfsChanged,proto3" json:"udfs_changed,omitempty"` + UdfsChanged bool `protobuf:"varint,9,opt,name=udfs_changed,json=udfsChanged,proto3" json:"udfs_changed,omitempty"` + TxUnresolved bool `protobuf:"varint,10,opt,name=tx_unresolved,json=txUnresolved,proto3" json:"tx_unresolved,omitempty"` } func (x *RealtimeStats) Reset() { @@ -5280,6 +5281,13 @@ func (x *RealtimeStats) GetUdfsChanged() bool { return false } +func (x *RealtimeStats) GetTxUnresolved() bool { + if x != nil { + return x.TxUnresolved + } + return false +} + // AggregateStats contains information about the health of a group of // tablets for a Target. It is used to propagate stats from a vtgate // to another, or from the Gateway layer of a vtgate to the routing @@ -6605,7 +6613,7 @@ var file_query_proto_rawDesc = []byte{ 0x65, 0x72, 0x76, 0x65, 0x64, 0x49, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x99, 0x03, 0x0a, 0x0d, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, + 0x74, 0x22, 0xbe, 0x03, 0x0a, 0x0d, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x36, 0x0a, 0x17, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, @@ -6630,154 +6638,156 @@ var file_query_proto_rawDesc = []byte{ 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x76, 0x69, 0x65, 0x77, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x64, 0x66, 0x73, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0b, 0x75, 0x64, 0x66, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x22, 0xf6, 0x01, - 0x0a, 0x0e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x12, 0x30, 0x0a, 0x14, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, - 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x16, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x14, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x54, 0x61, 0x62, - 0x6c, 0x65, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3d, 0x0a, 0x1b, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x61, 0x67, 0x5f, 0x73, 0x65, 0x63, 0x6f, - 0x6e, 0x64, 0x73, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x18, 0x72, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x67, 0x53, 0x65, 0x63, - 0x6f, 0x6e, 0x64, 0x73, 0x4d, 0x69, 0x6e, 0x12, 0x3d, 0x0a, 0x1b, 0x72, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x61, 0x67, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, - 0x64, 0x73, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x18, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x67, 0x53, 0x65, 0x63, 0x6f, - 0x6e, 0x64, 0x73, 0x4d, 0x61, 0x78, 0x22, 0x95, 0x02, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x25, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0d, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x06, - 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, - 0x12, 0x3f, 0x0a, 0x1c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x65, 0x72, 0x6d, - 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x19, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x54, - 0x65, 0x72, 0x6d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x12, 0x3b, 0x0a, 0x0e, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x73, 0x74, - 0x61, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, - 0x0d, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x38, - 0x0a, 0x0c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x54, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x0b, 0x74, 0x61, 0x62, - 0x6c, 0x65, 0x74, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x22, 0xae, - 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x74, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x74, 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x05, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, - 0x65, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x31, 0x0a, 0x0c, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, - 0x74, 0x52, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x22, - 0x91, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x01, + 0x52, 0x0b, 0x75, 0x64, 0x66, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x12, 0x23, 0x0a, + 0x0d, 0x74, 0x78, 0x5f, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x74, 0x78, 0x55, 0x6e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x64, 0x22, 0xf6, 0x01, 0x0a, 0x0e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, + 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x12, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x54, 0x61, 0x62, 0x6c, + 0x65, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x16, 0x75, 0x6e, 0x68, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, + 0x68, 0x79, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3d, 0x0a, + 0x1b, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x61, 0x67, + 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x18, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, + 0x61, 0x67, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4d, 0x69, 0x6e, 0x12, 0x3d, 0x0a, 0x1b, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x61, 0x67, 0x5f, + 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x18, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, + 0x67, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4d, 0x61, 0x78, 0x22, 0x95, 0x02, 0x0a, 0x14, + 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x35, 0x0a, 0x0a, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x16, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x54, 0x61, - 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x61, - 0x6d, 0x65, 0x73, 0x22, 0x6d, 0x0a, 0x07, 0x55, 0x44, 0x46, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6e, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x69, 0x6e, 0x67, 0x12, 0x2c, 0x0a, 0x0b, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79, - 0x70, 0x65, 0x22, 0xd5, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x75, 0x64, 0x66, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x55, - 0x44, 0x46, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x75, 0x64, 0x66, 0x73, 0x12, 0x58, 0x0a, 0x10, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x47, - 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x44, 0x65, 0x66, 0x69, - 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x42, 0x0a, 0x14, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x44, - 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x92, 0x03, 0x0a, 0x09, 0x4d, - 0x79, 0x53, 0x71, 0x6c, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x4d, 0x50, 0x54, - 0x59, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x54, 0x5f, 0x4e, 0x55, 0x4c, 0x4c, 0x5f, - 0x46, 0x4c, 0x41, 0x47, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x5f, 0x4b, 0x45, - 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x55, 0x4e, 0x49, 0x51, - 0x55, 0x45, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x04, 0x12, 0x15, 0x0a, - 0x11, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4c, 0x45, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, - 0x41, 0x47, 0x10, 0x08, 0x12, 0x0d, 0x0a, 0x09, 0x42, 0x4c, 0x4f, 0x42, 0x5f, 0x46, 0x4c, 0x41, - 0x47, 0x10, 0x10, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x4e, 0x53, 0x49, 0x47, 0x4e, 0x45, 0x44, 0x5f, - 0x46, 0x4c, 0x41, 0x47, 0x10, 0x20, 0x12, 0x11, 0x0a, 0x0d, 0x5a, 0x45, 0x52, 0x4f, 0x46, 0x49, - 0x4c, 0x4c, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x40, 0x12, 0x10, 0x0a, 0x0b, 0x42, 0x49, 0x4e, - 0x41, 0x52, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x01, 0x12, 0x0e, 0x0a, 0x09, 0x45, - 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x02, 0x12, 0x18, 0x0a, 0x13, 0x41, - 0x55, 0x54, 0x4f, 0x5f, 0x49, 0x4e, 0x43, 0x52, 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x46, 0x4c, - 0x41, 0x47, 0x10, 0x80, 0x04, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x49, 0x4d, 0x45, 0x53, 0x54, 0x41, - 0x4d, 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x08, 0x12, 0x0d, 0x0a, 0x08, 0x53, 0x45, - 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x10, 0x12, 0x1a, 0x0a, 0x15, 0x4e, 0x4f, 0x5f, - 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x5f, 0x46, 0x4c, - 0x41, 0x47, 0x10, 0x80, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x4f, 0x4e, 0x5f, 0x55, 0x50, 0x44, 0x41, - 0x54, 0x45, 0x5f, 0x4e, 0x4f, 0x57, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x40, 0x12, 0x0e, - 0x0a, 0x08, 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x02, 0x12, 0x13, - 0x0a, 0x0d, 0x50, 0x41, 0x52, 0x54, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, - 0x80, 0x80, 0x01, 0x12, 0x10, 0x0a, 0x0a, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x46, 0x4c, 0x41, - 0x47, 0x10, 0x80, 0x80, 0x02, 0x12, 0x11, 0x0a, 0x0b, 0x55, 0x4e, 0x49, 0x51, 0x55, 0x45, 0x5f, - 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x04, 0x12, 0x11, 0x0a, 0x0b, 0x42, 0x49, 0x4e, 0x43, - 0x4d, 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x08, 0x1a, 0x02, 0x10, 0x01, 0x2a, - 0x6b, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, - 0x00, 0x12, 0x0f, 0x0a, 0x0a, 0x49, 0x53, 0x49, 0x4e, 0x54, 0x45, 0x47, 0x52, 0x41, 0x4c, 0x10, - 0x80, 0x02, 0x12, 0x0f, 0x0a, 0x0a, 0x49, 0x53, 0x55, 0x4e, 0x53, 0x49, 0x47, 0x4e, 0x45, 0x44, - 0x10, 0x80, 0x04, 0x12, 0x0c, 0x0a, 0x07, 0x49, 0x53, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x10, 0x80, - 0x08, 0x12, 0x0d, 0x0a, 0x08, 0x49, 0x53, 0x51, 0x55, 0x4f, 0x54, 0x45, 0x44, 0x10, 0x80, 0x10, - 0x12, 0x0b, 0x0a, 0x06, 0x49, 0x53, 0x54, 0x45, 0x58, 0x54, 0x10, 0x80, 0x20, 0x12, 0x0d, 0x0a, - 0x08, 0x49, 0x53, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x80, 0x40, 0x2a, 0xc0, 0x03, 0x0a, - 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x55, 0x4c, 0x4c, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x04, 0x49, 0x4e, 0x54, 0x38, 0x10, 0x81, 0x02, 0x12, - 0x0a, 0x0a, 0x05, 0x55, 0x49, 0x4e, 0x54, 0x38, 0x10, 0x82, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, - 0x4e, 0x54, 0x31, 0x36, 0x10, 0x83, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x31, - 0x36, 0x10, 0x84, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x32, 0x34, 0x10, 0x85, 0x02, - 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x32, 0x34, 0x10, 0x86, 0x06, 0x12, 0x0a, 0x0a, - 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x87, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, - 0x54, 0x33, 0x32, 0x10, 0x88, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, - 0x89, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x8a, 0x06, 0x12, - 0x0c, 0x0a, 0x07, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x33, 0x32, 0x10, 0x8b, 0x08, 0x12, 0x0c, 0x0a, - 0x07, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x36, 0x34, 0x10, 0x8c, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x54, - 0x49, 0x4d, 0x45, 0x53, 0x54, 0x41, 0x4d, 0x50, 0x10, 0x8d, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x44, - 0x41, 0x54, 0x45, 0x10, 0x8e, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x8f, - 0x10, 0x12, 0x0d, 0x0a, 0x08, 0x44, 0x41, 0x54, 0x45, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x90, 0x10, - 0x12, 0x09, 0x0a, 0x04, 0x59, 0x45, 0x41, 0x52, 0x10, 0x91, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x44, - 0x45, 0x43, 0x49, 0x4d, 0x41, 0x4c, 0x10, 0x12, 0x12, 0x09, 0x0a, 0x04, 0x54, 0x45, 0x58, 0x54, - 0x10, 0x93, 0x30, 0x12, 0x09, 0x0a, 0x04, 0x42, 0x4c, 0x4f, 0x42, 0x10, 0x94, 0x50, 0x12, 0x0c, - 0x0a, 0x07, 0x56, 0x41, 0x52, 0x43, 0x48, 0x41, 0x52, 0x10, 0x95, 0x30, 0x12, 0x0e, 0x0a, 0x09, - 0x56, 0x41, 0x52, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x96, 0x50, 0x12, 0x09, 0x0a, 0x04, - 0x43, 0x48, 0x41, 0x52, 0x10, 0x97, 0x30, 0x12, 0x0b, 0x0a, 0x06, 0x42, 0x49, 0x4e, 0x41, 0x52, - 0x59, 0x10, 0x98, 0x50, 0x12, 0x08, 0x0a, 0x03, 0x42, 0x49, 0x54, 0x10, 0x99, 0x10, 0x12, 0x09, - 0x0a, 0x04, 0x45, 0x4e, 0x55, 0x4d, 0x10, 0x9a, 0x10, 0x12, 0x08, 0x0a, 0x03, 0x53, 0x45, 0x54, - 0x10, 0x9b, 0x10, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x55, 0x50, 0x4c, 0x45, 0x10, 0x1c, 0x12, 0x0d, - 0x0a, 0x08, 0x47, 0x45, 0x4f, 0x4d, 0x45, 0x54, 0x52, 0x59, 0x10, 0x9d, 0x10, 0x12, 0x09, 0x0a, - 0x04, 0x4a, 0x53, 0x4f, 0x4e, 0x10, 0x9e, 0x10, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x58, 0x50, 0x52, - 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x1f, 0x12, 0x0b, 0x0a, 0x06, 0x48, 0x45, 0x58, 0x4e, - 0x55, 0x4d, 0x10, 0xa0, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x48, 0x45, 0x58, 0x56, 0x41, 0x4c, 0x10, - 0xa1, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x42, 0x49, 0x54, 0x4e, 0x55, 0x4d, 0x10, 0xa2, 0x20, 0x2a, - 0x46, 0x0a, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, - 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, 0x01, 0x12, 0x0a, 0x0a, - 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x4f, 0x4c, - 0x4c, 0x42, 0x41, 0x43, 0x4b, 0x10, 0x03, 0x2a, 0x3b, 0x0a, 0x0f, 0x53, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x56, 0x49, - 0x45, 0x57, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x53, 0x10, - 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x44, - 0x46, 0x53, 0x10, 0x03, 0x42, 0x35, 0x0a, 0x0f, 0x69, 0x6f, 0x2e, 0x76, 0x69, 0x74, 0x65, 0x73, - 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x22, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, - 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x67, 0x65, 0x74, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x6e, 0x67, 0x12, 0x3f, 0x0a, 0x1c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, + 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x19, 0x70, 0x72, 0x69, + 0x6d, 0x61, 0x72, 0x79, 0x54, 0x65, 0x72, 0x6d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3b, 0x0a, 0x0e, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, + 0x6d, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, + 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x52, 0x0d, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x12, 0x38, 0x0a, 0x0c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x5f, 0x61, 0x6c, + 0x69, 0x61, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x6f, 0x70, 0x6f, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x41, 0x6c, 0x69, 0x61, 0x73, + 0x52, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x74, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x4a, 0x04, 0x08, + 0x06, 0x10, 0x07, 0x22, 0xae, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x74, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x74, 0x69, 0x64, 0x12, + 0x2d, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, + 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x21, + 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x64, 0x12, 0x31, 0x0a, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x73, 0x22, 0x91, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x12, 0x35, 0x0a, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x6d, 0x0a, 0x07, 0x55, 0x44, 0x46, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x67, + 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x2c, 0x0a, 0x0b, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, + 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0xd5, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, + 0x04, 0x75, 0x64, 0x66, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x55, 0x44, 0x46, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x75, 0x64, 0x66, + 0x73, 0x12, 0x58, 0x0a, 0x10, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0f, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x42, 0x0a, 0x14, 0x54, + 0x61, 0x62, 0x6c, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, + 0x92, 0x03, 0x0a, 0x09, 0x4d, 0x79, 0x53, 0x71, 0x6c, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x09, 0x0a, + 0x05, 0x45, 0x4d, 0x50, 0x54, 0x59, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x54, 0x5f, + 0x4e, 0x55, 0x4c, 0x4c, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x50, + 0x52, 0x49, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, + 0x0f, 0x55, 0x4e, 0x49, 0x51, 0x55, 0x45, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, + 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4c, 0x45, 0x5f, 0x4b, + 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x08, 0x12, 0x0d, 0x0a, 0x09, 0x42, 0x4c, 0x4f, + 0x42, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x10, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x4e, 0x53, 0x49, + 0x47, 0x4e, 0x45, 0x44, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x20, 0x12, 0x11, 0x0a, 0x0d, 0x5a, + 0x45, 0x52, 0x4f, 0x46, 0x49, 0x4c, 0x4c, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x40, 0x12, 0x10, + 0x0a, 0x0b, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x01, + 0x12, 0x0e, 0x0a, 0x09, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x02, + 0x12, 0x18, 0x0a, 0x13, 0x41, 0x55, 0x54, 0x4f, 0x5f, 0x49, 0x4e, 0x43, 0x52, 0x45, 0x4d, 0x45, + 0x4e, 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x04, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x49, + 0x4d, 0x45, 0x53, 0x54, 0x41, 0x4d, 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x08, 0x12, + 0x0d, 0x0a, 0x08, 0x53, 0x45, 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x10, 0x12, 0x1a, + 0x0a, 0x15, 0x4e, 0x4f, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x56, 0x41, 0x4c, + 0x55, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x4f, 0x4e, + 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x4e, 0x4f, 0x57, 0x5f, 0x46, 0x4c, 0x41, 0x47, + 0x10, 0x80, 0x40, 0x12, 0x0e, 0x0a, 0x08, 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, + 0x80, 0x80, 0x02, 0x12, 0x13, 0x0a, 0x0d, 0x50, 0x41, 0x52, 0x54, 0x5f, 0x4b, 0x45, 0x59, 0x5f, + 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x01, 0x12, 0x10, 0x0a, 0x0a, 0x47, 0x52, 0x4f, 0x55, + 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x02, 0x12, 0x11, 0x0a, 0x0b, 0x55, 0x4e, + 0x49, 0x51, 0x55, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x04, 0x12, 0x11, 0x0a, + 0x0b, 0x42, 0x49, 0x4e, 0x43, 0x4d, 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x08, + 0x1a, 0x02, 0x10, 0x01, 0x2a, 0x6b, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x08, 0x0a, 0x04, + 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0a, 0x49, 0x53, 0x49, 0x4e, 0x54, 0x45, + 0x47, 0x52, 0x41, 0x4c, 0x10, 0x80, 0x02, 0x12, 0x0f, 0x0a, 0x0a, 0x49, 0x53, 0x55, 0x4e, 0x53, + 0x49, 0x47, 0x4e, 0x45, 0x44, 0x10, 0x80, 0x04, 0x12, 0x0c, 0x0a, 0x07, 0x49, 0x53, 0x46, 0x4c, + 0x4f, 0x41, 0x54, 0x10, 0x80, 0x08, 0x12, 0x0d, 0x0a, 0x08, 0x49, 0x53, 0x51, 0x55, 0x4f, 0x54, + 0x45, 0x44, 0x10, 0x80, 0x10, 0x12, 0x0b, 0x0a, 0x06, 0x49, 0x53, 0x54, 0x45, 0x58, 0x54, 0x10, + 0x80, 0x20, 0x12, 0x0d, 0x0a, 0x08, 0x49, 0x53, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x80, + 0x40, 0x2a, 0xc0, 0x03, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x55, + 0x4c, 0x4c, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x04, 0x49, 0x4e, 0x54, + 0x38, 0x10, 0x81, 0x02, 0x12, 0x0a, 0x0a, 0x05, 0x55, 0x49, 0x4e, 0x54, 0x38, 0x10, 0x82, 0x06, + 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x31, 0x36, 0x10, 0x83, 0x02, 0x12, 0x0b, 0x0a, 0x06, + 0x55, 0x49, 0x4e, 0x54, 0x31, 0x36, 0x10, 0x84, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, + 0x32, 0x34, 0x10, 0x85, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x32, 0x34, 0x10, + 0x86, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x87, 0x02, 0x12, 0x0b, + 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x88, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, + 0x4e, 0x54, 0x36, 0x34, 0x10, 0x89, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, + 0x34, 0x10, 0x8a, 0x06, 0x12, 0x0c, 0x0a, 0x07, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x33, 0x32, 0x10, + 0x8b, 0x08, 0x12, 0x0c, 0x0a, 0x07, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x36, 0x34, 0x10, 0x8c, 0x08, + 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x49, 0x4d, 0x45, 0x53, 0x54, 0x41, 0x4d, 0x50, 0x10, 0x8d, 0x10, + 0x12, 0x09, 0x0a, 0x04, 0x44, 0x41, 0x54, 0x45, 0x10, 0x8e, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x54, + 0x49, 0x4d, 0x45, 0x10, 0x8f, 0x10, 0x12, 0x0d, 0x0a, 0x08, 0x44, 0x41, 0x54, 0x45, 0x54, 0x49, + 0x4d, 0x45, 0x10, 0x90, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x59, 0x45, 0x41, 0x52, 0x10, 0x91, 0x06, + 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x43, 0x49, 0x4d, 0x41, 0x4c, 0x10, 0x12, 0x12, 0x09, 0x0a, + 0x04, 0x54, 0x45, 0x58, 0x54, 0x10, 0x93, 0x30, 0x12, 0x09, 0x0a, 0x04, 0x42, 0x4c, 0x4f, 0x42, + 0x10, 0x94, 0x50, 0x12, 0x0c, 0x0a, 0x07, 0x56, 0x41, 0x52, 0x43, 0x48, 0x41, 0x52, 0x10, 0x95, + 0x30, 0x12, 0x0e, 0x0a, 0x09, 0x56, 0x41, 0x52, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x96, + 0x50, 0x12, 0x09, 0x0a, 0x04, 0x43, 0x48, 0x41, 0x52, 0x10, 0x97, 0x30, 0x12, 0x0b, 0x0a, 0x06, + 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x98, 0x50, 0x12, 0x08, 0x0a, 0x03, 0x42, 0x49, 0x54, + 0x10, 0x99, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x45, 0x4e, 0x55, 0x4d, 0x10, 0x9a, 0x10, 0x12, 0x08, + 0x0a, 0x03, 0x53, 0x45, 0x54, 0x10, 0x9b, 0x10, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x55, 0x50, 0x4c, + 0x45, 0x10, 0x1c, 0x12, 0x0d, 0x0a, 0x08, 0x47, 0x45, 0x4f, 0x4d, 0x45, 0x54, 0x52, 0x59, 0x10, + 0x9d, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x4a, 0x53, 0x4f, 0x4e, 0x10, 0x9e, 0x10, 0x12, 0x0e, 0x0a, + 0x0a, 0x45, 0x58, 0x50, 0x52, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x1f, 0x12, 0x0b, 0x0a, + 0x06, 0x48, 0x45, 0x58, 0x4e, 0x55, 0x4d, 0x10, 0xa0, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x48, 0x45, + 0x58, 0x56, 0x41, 0x4c, 0x10, 0xa1, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x42, 0x49, 0x54, 0x4e, 0x55, + 0x4d, 0x10, 0xa2, 0x20, 0x2a, 0x46, 0x0a, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, + 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x02, 0x12, 0x0c, + 0x0a, 0x08, 0x52, 0x4f, 0x4c, 0x4c, 0x42, 0x41, 0x43, 0x4b, 0x10, 0x03, 0x2a, 0x3b, 0x0a, 0x0f, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x09, 0x0a, 0x05, 0x56, 0x49, 0x45, 0x57, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x41, + 0x42, 0x4c, 0x45, 0x53, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x12, + 0x08, 0x0a, 0x04, 0x55, 0x44, 0x46, 0x53, 0x10, 0x03, 0x42, 0x35, 0x0a, 0x0f, 0x69, 0x6f, 0x2e, + 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x22, 0x76, 0x69, + 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, + 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go/vt/proto/query/query_vtproto.pb.go b/go/vt/proto/query/query_vtproto.pb.go index 8092c6abe19..c7069cfd6d7 100644 --- a/go/vt/proto/query/query_vtproto.pb.go +++ b/go/vt/proto/query/query_vtproto.pb.go @@ -1403,6 +1403,7 @@ func (m *RealtimeStats) CloneVT() *RealtimeStats { CpuUsage: m.CpuUsage, Qps: m.Qps, UdfsChanged: m.UdfsChanged, + TxUnresolved: m.TxUnresolved, } if rhs := m.TableSchemaChanged; rhs != nil { tmpContainer := make([]string, len(rhs)) @@ -5523,6 +5524,16 @@ func (m *RealtimeStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.TxUnresolved { + i-- + if m.TxUnresolved { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x50 + } if m.UdfsChanged { i-- if m.UdfsChanged { @@ -7527,6 +7538,9 @@ func (m *RealtimeStats) SizeVT() (n int) { if m.UdfsChanged { n += 2 } + if m.TxUnresolved { + n += 2 + } n += len(m.unknownFields) return n } @@ -18111,6 +18125,26 @@ func (m *RealtimeStats) UnmarshalVT(dAtA []byte) error { } } m.UdfsChanged = bool(v != 0) + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TxUnresolved", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.TxUnresolved = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/proto/query.proto b/proto/query.proto index 8af243f0ef9..5253e32a182 100644 --- a/proto/query.proto +++ b/proto/query.proto @@ -898,6 +898,8 @@ message RealtimeStats { // udfs_changed is used to signal that the UDFs have changed on the tablet. bool udfs_changed = 9; + + bool tx_unresolved = 10; } // AggregateStats contains information about the health of a group of diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 6598523835c..60eb550ec67 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -42594,6 +42594,9 @@ export namespace query { /** RealtimeStats udfs_changed */ udfs_changed?: (boolean|null); + + /** RealtimeStats tx_unresolved */ + tx_unresolved?: (boolean|null); } /** Represents a RealtimeStats. */ @@ -42632,6 +42635,9 @@ export namespace query { /** RealtimeStats udfs_changed. */ public udfs_changed: boolean; + /** RealtimeStats tx_unresolved. */ + public tx_unresolved: boolean; + /** * Creates a new RealtimeStats instance using the specified properties. * @param [properties] Properties to set diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 997c7c1f08b..99ee1e84900 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -103280,6 +103280,7 @@ export const query = $root.query = (() => { * @property {Array.|null} [table_schema_changed] RealtimeStats table_schema_changed * @property {Array.|null} [view_schema_changed] RealtimeStats view_schema_changed * @property {boolean|null} [udfs_changed] RealtimeStats udfs_changed + * @property {boolean|null} [tx_unresolved] RealtimeStats tx_unresolved */ /** @@ -103371,6 +103372,14 @@ export const query = $root.query = (() => { */ RealtimeStats.prototype.udfs_changed = false; + /** + * RealtimeStats tx_unresolved. + * @member {boolean} tx_unresolved + * @memberof query.RealtimeStats + * @instance + */ + RealtimeStats.prototype.tx_unresolved = false; + /** * Creates a new RealtimeStats instance using the specified properties. * @function create @@ -103415,6 +103424,8 @@ export const query = $root.query = (() => { writer.uint32(/* id 8, wireType 2 =*/66).string(message.view_schema_changed[i]); if (message.udfs_changed != null && Object.hasOwnProperty.call(message, "udfs_changed")) writer.uint32(/* id 9, wireType 0 =*/72).bool(message.udfs_changed); + if (message.tx_unresolved != null && Object.hasOwnProperty.call(message, "tx_unresolved")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.tx_unresolved); return writer; }; @@ -103489,6 +103500,10 @@ export const query = $root.query = (() => { message.udfs_changed = reader.bool(); break; } + case 10: { + message.tx_unresolved = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -103559,6 +103574,9 @@ export const query = $root.query = (() => { if (message.udfs_changed != null && message.hasOwnProperty("udfs_changed")) if (typeof message.udfs_changed !== "boolean") return "udfs_changed: boolean expected"; + if (message.tx_unresolved != null && message.hasOwnProperty("tx_unresolved")) + if (typeof message.tx_unresolved !== "boolean") + return "tx_unresolved: boolean expected"; return null; }; @@ -103609,6 +103627,8 @@ export const query = $root.query = (() => { } if (object.udfs_changed != null) message.udfs_changed = Boolean(object.udfs_changed); + if (object.tx_unresolved != null) + message.tx_unresolved = Boolean(object.tx_unresolved); return message; }; @@ -103641,6 +103661,7 @@ export const query = $root.query = (() => { object.cpu_usage = 0; object.qps = 0; object.udfs_changed = false; + object.tx_unresolved = false; } if (message.health_error != null && message.hasOwnProperty("health_error")) object.health_error = message.health_error; @@ -103669,6 +103690,8 @@ export const query = $root.query = (() => { } if (message.udfs_changed != null && message.hasOwnProperty("udfs_changed")) object.udfs_changed = message.udfs_changed; + if (message.tx_unresolved != null && message.hasOwnProperty("tx_unresolved")) + object.tx_unresolved = message.tx_unresolved; return object; }; From 81de2fbb1a86d093bd52895521d2d1e143e9c46f Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Wed, 10 Jul 2024 20:24:02 +0530 Subject: [PATCH 2/9] feat: notify unresolved transaction through health stream using transaction watcher Signed-off-by: Harshit Gangal --- go/flags/endtoend/vtcombo.txt | 1 - go/flags/endtoend/vttablet.txt | 2 - .../vtgate/transaction/twopc/main_test.go | 1 - .../endtoend/vtgate/transaction/tx_test.go | 1 - go/vt/sidecardb/schema/twopc/dt_state.sql | 3 +- go/vt/vtexplain/vtexplain_vttablet.go | 1 - .../vttablet/tabletserver/health_streamer.go | 29 ++++++++--- .../tabletserver/query_executor_test.go | 1 - .../vttablet/tabletserver/tabletenv/config.go | 14 +++-- go/vt/vttablet/tabletserver/tabletserver.go | 2 +- go/vt/vttablet/tabletserver/twopc.go | 35 ++----------- go/vt/vttablet/tabletserver/tx_engine.go | 51 +++++-------------- go/vt/vttablet/tabletserver/tx_engine_test.go | 10 ++-- 13 files changed, 53 insertions(+), 98 deletions(-) diff --git a/go/flags/endtoend/vtcombo.txt b/go/flags/endtoend/vtcombo.txt index 743bbf5b7bb..c59cd789ed3 100644 --- a/go/flags/endtoend/vtcombo.txt +++ b/go/flags/endtoend/vtcombo.txt @@ -389,7 +389,6 @@ Flags: --transaction_mode string SINGLE: disallow multi-db transactions, MULTI: allow multi-db transactions with best effort commit, TWOPC: allow multi-db transactions with 2pc commit (default "MULTI") --truncate-error-len int truncate errors sent to client if they are longer than this value (0 means do not truncate) --twopc_abandon_age float time in seconds. Any unresolved transaction older than this time will be sent to the coordinator to be resolved. - --twopc_coordinator_address string address of the (VTGate) process(es) that will be used to notify of abandoned transactions. --twopc_enable if the flag is on, 2pc is enabled. Other 2pc flags must be supplied. --tx-throttler-config string Synonym to -tx_throttler_config (default "target_replication_lag_sec:2 max_replication_lag_sec:10 initial_rate:100 max_increase:1 emergency_decrease:0.5 min_duration_between_increases_sec:40 max_duration_between_increases_sec:62 min_duration_between_decreases_sec:20 spread_backlog_across_sec:20 age_bad_rate_after_sec:180 bad_rate_increase:0.1 max_rate_approach_threshold:0.9") --tx-throttler-default-priority int Default priority assigned to queries that lack priority information (default 100) diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index 40d686979c0..f5a7f8e8f51 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -387,7 +387,6 @@ Flags: --transaction_limit_by_username Include VTGateCallerID.username when considering who the user is for the purpose of transaction limit. (default true) --transaction_limit_per_user float Maximum number of transactions a single user is allowed to use at any time, represented as fraction of -transaction_cap. (default 0.4) --twopc_abandon_age float time in seconds. Any unresolved transaction older than this time will be sent to the coordinator to be resolved. - --twopc_coordinator_address string address of the (VTGate) process(es) that will be used to notify of abandoned transactions. --twopc_enable if the flag is on, 2pc is enabled. Other 2pc flags must be supplied. --tx-throttler-config string Synonym to -tx_throttler_config (default "target_replication_lag_sec:2 max_replication_lag_sec:10 initial_rate:100 max_increase:1 emergency_decrease:0.5 min_duration_between_increases_sec:40 max_duration_between_increases_sec:62 min_duration_between_decreases_sec:20 spread_backlog_across_sec:20 age_bad_rate_after_sec:180 bad_rate_increase:0.1 max_rate_approach_threshold:0.9") --tx-throttler-default-priority int Default priority assigned to queries that lack priority information (default 100) @@ -417,7 +416,6 @@ Flags: --vstream-binlog-rotation-threshold int Byte size at which a VStreamer will attempt to rotate the source's open binary log before starting a GTID snapshot based stream (e.g. a ResultStreamer or RowStreamer) (default 67108864) --vstream_dynamic_packet_size Enable dynamic packet sizing for VReplication. This will adjust the packet size during replication to improve performance. (default true) --vstream_packet_size int Suggested packet size for VReplication streamer. This is used only as a recommendation. The actual packet size may be more or less than this amount. (default 250000) - --vtgate_protocol string how to talk to vtgate (default "grpc") --vttablet_skip_buildinfo_tags string comma-separated list of buildinfo tags to skip from merging with --init_tags. each tag is either an exact match or a regular expression of the form '/regexp/'. (default "/.*/") --wait_for_backup_interval duration (init restore parameter) if this is greater than 0, instead of starting up empty when no backups are found, keep checking at this interval for a backup to appear --watch_replication_stream When enabled, vttablet will stream the MySQL replication stream from the local server, and use it to update schema when it sees a DDL. diff --git a/go/test/endtoend/vtgate/transaction/twopc/main_test.go b/go/test/endtoend/vtgate/transaction/twopc/main_test.go index 102235d672a..af5c1a395ad 100644 --- a/go/test/endtoend/vtgate/transaction/twopc/main_test.go +++ b/go/test/endtoend/vtgate/transaction/twopc/main_test.go @@ -78,7 +78,6 @@ func TestMain(m *testing.M) { ) clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--twopc_enable", - "--twopc_coordinator_address", fmt.Sprintf("localhost:%d", clusterInstance.VtgateGrpcPort), "--twopc_abandon_age", "3600", "--queryserver-config-transaction-cap", "3", ) diff --git a/go/test/endtoend/vtgate/transaction/tx_test.go b/go/test/endtoend/vtgate/transaction/tx_test.go index 8a004277b89..40621a1d84b 100644 --- a/go/test/endtoend/vtgate/transaction/tx_test.go +++ b/go/test/endtoend/vtgate/transaction/tx_test.go @@ -59,7 +59,6 @@ func TestMain(m *testing.M) { // Set extra tablet args for twopc clusterInstance.VtTabletExtraArgs = []string{ "--twopc_enable", - "--twopc_coordinator_address", fmt.Sprintf("localhost:%d", clusterInstance.VtgateGrpcPort), "--twopc_abandon_age", "3600", } diff --git a/go/vt/sidecardb/schema/twopc/dt_state.sql b/go/vt/sidecardb/schema/twopc/dt_state.sql index dff9e4c3770..9841679ef02 100644 --- a/go/vt/sidecardb/schema/twopc/dt_state.sql +++ b/go/vt/sidecardb/schema/twopc/dt_state.sql @@ -19,5 +19,6 @@ CREATE TABLE IF NOT EXISTS dt_state dtid varbinary(512) NOT NULL, state bigint NOT NULL, time_created bigint NOT NULL, - primary key(dtid) + primary key(dtid), + key (time_created), ) ENGINE = InnoDB diff --git a/go/vt/vtexplain/vtexplain_vttablet.go b/go/vt/vtexplain/vtexplain_vttablet.go index 3f9aee0efa3..ed977e7bcb0 100644 --- a/go/vt/vtexplain/vtexplain_vttablet.go +++ b/go/vt/vtexplain/vtexplain_vttablet.go @@ -113,7 +113,6 @@ func (vte *VTExplain) newTablet(ctx context.Context, env *vtenv.Environment, opt config := tabletenv.NewCurrentConfig() config.TrackSchemaVersions = false if opts.ExecutionMode == ModeTwoPC { - config.TwoPCCoordinatorAddress = "XXX" config.TwoPCAbandonAge = 1.0 config.TwoPCEnable = true } diff --git a/go/vt/vttablet/tabletserver/health_streamer.go b/go/vt/vttablet/tabletserver/health_streamer.go index 269e3daefd6..02e4f1a3291 100644 --- a/go/vt/vttablet/tabletserver/health_streamer.go +++ b/go/vt/vttablet/tabletserver/health_streamer.go @@ -287,12 +287,14 @@ func (hs *healthStreamer) MakePrimary(serving bool) { hs.isServingPrimary = serving // We register for notifications from the schema Engine only when schema tracking is enabled, // and we are going to a serving primary state. - if serving && hs.signalWhenSchemaChange { - hs.se.RegisterNotifier("healthStreamer", func(full map[string]*schema.Table, created, altered, dropped []*schema.Table, udfsChanged bool) { - if err := hs.reload(created, altered, dropped, udfsChanged); err != nil { - log.Errorf("periodic schema reload failed in health stream: %v", err) - } - }, false) + if serving { + if hs.signalWhenSchemaChange { + hs.se.RegisterNotifier("healthStreamer", func(full map[string]*schema.Table, created, altered, dropped []*schema.Table, udfsChanged bool) { + if err := hs.reload(created, altered, dropped, udfsChanged); err != nil { + log.Errorf("periodic schema reload failed in health stream: %v", err) + } + }, false) + } } } @@ -346,3 +348,18 @@ func (hs *healthStreamer) reload(created, altered, dropped []*schema.Table, udfs hs.state.RealtimeStats.UdfsChanged = false return nil } + +// sendUnresolvedTransactionSignal sends broadcast message about unresolved transactions. +func (hs *healthStreamer) sendUnresolvedTransactionSignal() { + hs.mu.Lock() + defer hs.mu.Unlock() + // send signal only when primary is serving. + if !hs.isServingPrimary { + return + } + + hs.state.RealtimeStats.TxUnresolved = true + shr := hs.state.CloneVT() + hs.broadCastToClients(shr) + hs.state.RealtimeStats.TxUnresolved = false +} diff --git a/go/vt/vttablet/tabletserver/query_executor_test.go b/go/vt/vttablet/tabletserver/query_executor_test.go index c4f3ed1b00c..6ec2ffeec92 100644 --- a/go/vt/vttablet/tabletserver/query_executor_test.go +++ b/go/vt/vttablet/tabletserver/query_executor_test.go @@ -1513,7 +1513,6 @@ func newTestTabletServer(ctx context.Context, flags executorFlags, db *fakesqldb } else { cfg.EnableOnlineDDL = true } - cfg.TwoPCCoordinatorAddress = "fake" if flags&shortTwopcAge > 0 { cfg.TwoPCAbandonAge = 0.5 } else { diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 89f827fa1f3..9c25a97aec9 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -157,7 +157,6 @@ func registerTabletEnvFlags(fs *pflag.FlagSet) { fs.BoolVar(¤tConfig.TrackSchemaVersions, "track_schema_versions", false, "When enabled, vttablet will store versions of schemas at each position that a DDL is applied and allow retrieval of the schema corresponding to a position") fs.Int64Var(¤tConfig.SchemaVersionMaxAgeSeconds, "schema-version-max-age-seconds", 0, "max age of schema version records to kept in memory by the vreplication historian") fs.BoolVar(¤tConfig.TwoPCEnable, "twopc_enable", defaultConfig.TwoPCEnable, "if the flag is on, 2pc is enabled. Other 2pc flags must be supplied.") - fs.StringVar(¤tConfig.TwoPCCoordinatorAddress, "twopc_coordinator_address", defaultConfig.TwoPCCoordinatorAddress, "address of the (VTGate) process(es) that will be used to notify of abandoned transactions.") SecondsVar(fs, ¤tConfig.TwoPCAbandonAge, "twopc_abandon_age", defaultConfig.TwoPCAbandonAge, "time in seconds. Any unresolved transaction older than this time will be sent to the coordinator to be resolved.") // Tx throttler config flagutil.DualFormatBoolVar(fs, ¤tConfig.EnableTxThrottler, "enable_tx_throttler", defaultConfig.EnableTxThrottler, "If true replication-lag-based throttling on transactions will be enabled.") @@ -332,13 +331,12 @@ type TabletConfig struct { ExternalConnections map[string]*dbconfigs.DBConfigs `json:"externalConnections,omitempty"` - SanitizeLogMessages bool `json:"-"` - StrictTableACL bool `json:"-"` - EnableTableACLDryRun bool `json:"-"` - TableACLExemptACL string `json:"-"` - TwoPCEnable bool `json:"-"` - TwoPCCoordinatorAddress string `json:"-"` - TwoPCAbandonAge Seconds `json:"-"` + SanitizeLogMessages bool `json:"-"` + StrictTableACL bool `json:"-"` + EnableTableACLDryRun bool `json:"-"` + TableACLExemptACL string `json:"-"` + TwoPCEnable bool `json:"-"` + TwoPCAbandonAge Seconds `json:"-"` EnableTxThrottler bool `json:"-"` TxThrottlerConfig *TxThrottlerConfigFlag `json:"-"` diff --git a/go/vt/vttablet/tabletserver/tabletserver.go b/go/vt/vttablet/tabletserver/tabletserver.go index 06558b96145..8a6d1a0be39 100644 --- a/go/vt/vttablet/tabletserver/tabletserver.go +++ b/go/vt/vttablet/tabletserver/tabletserver.go @@ -181,7 +181,7 @@ func NewTabletServer(ctx context.Context, env *vtenv.Environment, name string, c tsv.watcher = NewBinlogWatcher(tsv, tsv.vstreamer, tsv.config) tsv.qe = NewQueryEngine(tsv, tsv.se) tsv.txThrottler = txthrottler.NewTxThrottler(tsv, topoServer) - tsv.te = NewTxEngine(tsv) + tsv.te = NewTxEngine(tsv, tsv.hs.sendUnresolvedTransactionSignal) tsv.messager = messager.NewEngine(tsv, tsv.se, tsv.vstreamer) tsv.tableGC = gc.NewTableGC(tsv, topoServer, tsv.lagThrottler) diff --git a/go/vt/vttablet/tabletserver/twopc.go b/go/vt/vttablet/tabletserver/twopc.go index ad652d43135..8d970916697 100644 --- a/go/vt/vttablet/tabletserver/twopc.go +++ b/go/vt/vttablet/tabletserver/twopc.go @@ -261,8 +261,8 @@ func (tpc *TwoPC) ReadAllRedo(ctx context.Context) (prepared, failed []*tx.Prepa return prepared, failed, nil } -// CountUnresolvedRedo returns the number of prepared transactions that are still unresolved. -func (tpc *TwoPC) CountUnresolvedRedo(ctx context.Context, unresolvedTime time.Time) (int64, error) { +// CountUnresolvedTransactions returns the number of prepared transactions that are still unresolved. +func (tpc *TwoPC) CountUnresolvedTransactions(ctx context.Context, unresolvedTime time.Time) (int64, error) { conn, err := tpc.readPool.Get(ctx, nil) if err != nil { return 0, err @@ -276,9 +276,7 @@ func (tpc *TwoPC) CountUnresolvedRedo(ctx context.Context, unresolvedTime time.T if err != nil { return 0, err } - if len(qr.Rows) < 1 { - return 0, nil - } + // executed query is a scalar aggregation, so we can safely assume that the result is a single row. v, _ := qr.Rows[0][0].ToCastInt64() return v, nil } @@ -395,33 +393,6 @@ func (tpc *TwoPC) ReadTransaction(ctx context.Context, dtid string) (*querypb.Tr return result, nil } -// ReadAbandoned returns the list of abandoned transactions -// and their associated start time. -func (tpc *TwoPC) ReadAbandoned(ctx context.Context, abandonTime time.Time) (map[string]time.Time, error) { - conn, err := tpc.readPool.Get(ctx, nil) - if err != nil { - return nil, err - } - defer conn.Recycle() - - bindVars := map[string]*querypb.BindVariable{ - "time_created": sqltypes.Int64BindVariable(abandonTime.UnixNano()), - } - qr, err := tpc.read(ctx, conn.Conn, tpc.readAbandoned, bindVars) - if err != nil { - return nil, err - } - txs := make(map[string]time.Time, len(qr.Rows)) - for _, row := range qr.Rows { - t, err := row[1].ToCastInt64() - if err != nil { - return nil, err - } - txs[row[0].ToString()] = time.Unix(0, t) - } - return txs, nil -} - // ReadAllTransactions returns info about all distributed transactions. func (tpc *TwoPC) ReadAllTransactions(ctx context.Context) ([]*tx.DistributedTx, error) { conn, err := tpc.readPool.Get(ctx, nil) diff --git a/go/vt/vttablet/tabletserver/tx_engine.go b/go/vt/vttablet/tabletserver/tx_engine.go index 3161f3b88c1..1fd87488cab 100644 --- a/go/vt/vttablet/tabletserver/tx_engine.go +++ b/go/vt/vttablet/tabletserver/tx_engine.go @@ -32,7 +32,6 @@ import ( vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/vterrors" - "vitess.io/vitess/go/vt/vtgate/vtgateconn" "vitess.io/vitess/go/vt/vttablet/tabletserver/connpool" "vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv" "vitess.io/vitess/go/vt/vttablet/tabletserver/tx" @@ -89,10 +88,11 @@ type TxEngine struct { preparedPool *TxPreparedPool twoPC *TwoPC twoPCReady sync.WaitGroup + dxNotify func() } // NewTxEngine creates a new TxEngine. -func NewTxEngine(env tabletenv.Env) *TxEngine { +func NewTxEngine(env tabletenv.Env, dxNotifier func()) *TxEngine { config := env.Config() te := &TxEngine{ env: env, @@ -103,16 +103,11 @@ func NewTxEngine(env tabletenv.Env) *TxEngine { te.txPool = NewTxPool(env, limiter) te.twopcEnabled = config.TwoPCEnable if te.twopcEnabled { - if config.TwoPCCoordinatorAddress == "" { - log.Error("Coordinator address not specified: Disabling 2PC") - te.twopcEnabled = false - } if config.TwoPCAbandonAge <= 0 { log.Error("2PC abandon age not specified: Disabling 2PC") te.twopcEnabled = false } } - te.coordinatorAddress = config.TwoPCCoordinatorAddress te.abandonAge = config.TwoPCAbandonAge.Get() te.ticks = timer.NewTimer(te.abandonAge / 2) @@ -127,6 +122,7 @@ func NewTxEngine(env tabletenv.Env) *TxEngine { IdleTimeout: env.Config().TxPool.IdleTimeout, }) te.twoPC = NewTwoPC(readPool) + te.dxNotify = dxNotifier te.state = NotServing return te } @@ -460,45 +456,24 @@ func (te *TxEngine) startWatchdog() { defer cancel() // Raise alerts on prepares that have been unresolved for too long. - // Use 5x abandonAge to give opportunity for watchdog to resolve these. - count, err := te.twoPC.CountUnresolvedRedo(ctx, time.Now().Add(-te.abandonAge*5)) + // Use 5x abandonAge to give opportunity for transaction coordinator to resolve these. + count, err := te.twoPC.CountUnresolvedTransactions(ctx, time.Now().Add(-te.abandonAge*5)) if err != nil { - te.env.Stats().InternalErrors.Add("WatchdogFail", 1) - log.Errorf("Error reading unresolved prepares: '%v': %v", te.coordinatorAddress, err) + te.env.Stats().InternalErrors.Add("DistributedTransactionWatcherFail", 1) + log.Errorf("Error reading unresolved transactions: %v", err) } te.env.Stats().Unresolved.Set("Prepares", count) - // Resolve lingering distributed transactions. - txs, err := te.twoPC.ReadAbandoned(ctx, time.Now().Add(-te.abandonAge)) - if err != nil { - te.env.Stats().InternalErrors.Add("WatchdogFail", 1) - log.Errorf("Error reading transactions for 2pc watchdog: %v", err) - return - } - if len(txs) == 0 { - return - } - - coordConn, err := vtgateconn.Dial(ctx, te.coordinatorAddress) + // Notify lingering distributed transactions. + count, err = te.twoPC.CountUnresolvedTransactions(ctx, time.Now().Add(-te.abandonAge)) if err != nil { - te.env.Stats().InternalErrors.Add("WatchdogFail", 1) - log.Errorf("Error connecting to coordinator '%v': %v", te.coordinatorAddress, err) + te.env.Stats().InternalErrors.Add("DistributedTransactionWatcherFail", 1) + log.Errorf("Error reading unresolved transactions: %v", err) return } - defer coordConn.Close() - - var wg sync.WaitGroup - for tx := range txs { - wg.Add(1) - go func(dtid string) { - defer wg.Done() - if err := coordConn.ResolveTransaction(ctx, dtid); err != nil { - te.env.Stats().InternalErrors.Add("WatchdogFail", 1) - log.Errorf("Error notifying for dtid %s: %v", dtid, err) - } - }(tx) + if count > 0 { + te.dxNotify() } - wg.Wait() }) } diff --git a/go/vt/vttablet/tabletserver/tx_engine_test.go b/go/vt/vttablet/tabletserver/tx_engine_test.go index 3c3a8a4eb4f..95057d754fb 100644 --- a/go/vt/vttablet/tabletserver/tx_engine_test.go +++ b/go/vt/vttablet/tabletserver/tx_engine_test.go @@ -49,7 +49,7 @@ func TestTxEngineClose(t *testing.T) { cfg.TxPool.Size = 10 cfg.Oltp.TxTimeout = 100 * time.Millisecond cfg.GracePeriods.Shutdown = 0 - te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest")) + te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest"), nil) // Normal close. te.AcceptReadWrite() @@ -152,7 +152,7 @@ func TestTxEngineBegin(t *testing.T) { db.AddQueryPattern(".*", &sqltypes.Result{}) cfg := tabletenv.NewDefaultConfig() cfg.DB = newDBConfigs(db) - te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest")) + te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest"), nil) for _, exec := range []func() (int64, string, error){ func() (int64, string, error) { @@ -198,7 +198,7 @@ func TestTxEngineRenewFails(t *testing.T) { db.AddQueryPattern(".*", &sqltypes.Result{}) cfg := tabletenv.NewDefaultConfig() cfg.DB = newDBConfigs(db) - te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest")) + te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest"), nil) te.AcceptReadOnly() options := &querypb.ExecuteOptions{} connID, _, err := te.ReserveBegin(ctx, options, nil, nil) @@ -536,7 +536,7 @@ func setupTxEngine(db *fakesqldb.DB) *TxEngine { cfg.TxPool.Size = 10 cfg.Oltp.TxTimeout = 100 * time.Millisecond cfg.GracePeriods.Shutdown = 0 - te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest")) + te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest"), nil) return te } @@ -568,7 +568,7 @@ func TestTxEngineFailReserve(t *testing.T) { db.AddQueryPattern(".*", &sqltypes.Result{}) cfg := tabletenv.NewDefaultConfig() cfg.DB = newDBConfigs(db) - te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest")) + te := NewTxEngine(tabletenv.NewEnv(vtenv.NewTestEnv(), cfg, "TabletServerTest"), nil) options := &querypb.ExecuteOptions{} _, err := te.Reserve(ctx, options, 0, nil) From 2aac6ae7202182e302499b913b2dd6b3520888c0 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 11 Jul 2024 13:03:20 +0530 Subject: [PATCH 3/9] remove coodinator address Signed-off-by: Harshit Gangal --- go/vt/vttablet/endtoend/framework/server.go | 1 - 1 file changed, 1 deletion(-) diff --git a/go/vt/vttablet/endtoend/framework/server.go b/go/vt/vttablet/endtoend/framework/server.go index 95c8114fd9f..07c4f0424ac 100644 --- a/go/vt/vttablet/endtoend/framework/server.go +++ b/go/vt/vttablet/endtoend/framework/server.go @@ -118,7 +118,6 @@ func StartServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnP config.StrictTableACL = true config.TwoPCEnable = true config.TwoPCAbandonAge = 1 - config.TwoPCCoordinatorAddress = "fake" config.HotRowProtection.Mode = tabletenv.Enable config.TrackSchemaVersions = true config.GracePeriods.Shutdown = 2 * time.Second From 65b502077e2733cdeb5b108218b053f22e903722 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 11 Jul 2024 13:29:35 +0530 Subject: [PATCH 4/9] fix: dt_state create statement Signed-off-by: Harshit Gangal --- go/vt/sidecardb/schema/twopc/dt_state.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/vt/sidecardb/schema/twopc/dt_state.sql b/go/vt/sidecardb/schema/twopc/dt_state.sql index 9841679ef02..9247ea5fa3c 100644 --- a/go/vt/sidecardb/schema/twopc/dt_state.sql +++ b/go/vt/sidecardb/schema/twopc/dt_state.sql @@ -20,5 +20,5 @@ CREATE TABLE IF NOT EXISTS dt_state state bigint NOT NULL, time_created bigint NOT NULL, primary key(dtid), - key (time_created), + key (time_created) ) ENGINE = InnoDB From cd7b70758512ec196df65fc6e0fbc4eeb6d62fb5 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 11 Jul 2024 17:48:16 +0530 Subject: [PATCH 5/9] count on dt_state and dt_redo for unresolved transactions and unresolved prepared transactions Signed-off-by: Harshit Gangal --- go/vt/proto/query/query.pb.go | 16 +++--- .../tabletserver/query_executor_test.go | 8 +-- .../tabletserver/tabletserver_test.go | 8 +-- go/vt/vttablet/tabletserver/twopc.go | 51 ++++++++++++++----- go/vt/vttablet/tabletserver/tx_engine.go | 12 ++--- proto/query.proto | 4 +- web/vtadmin/src/proto/vtadmin.d.ts | 4 +- web/vtadmin/src/proto/vtadmin.js | 12 ++--- 8 files changed, 70 insertions(+), 45 deletions(-) diff --git a/go/vt/proto/query/query.pb.go b/go/vt/proto/query/query.pb.go index dd88e67af22..c10568cc69b 100644 --- a/go/vt/proto/query/query.pb.go +++ b/go/vt/proto/query/query.pb.go @@ -428,8 +428,8 @@ type TransactionState int32 const ( TransactionState_UNKNOWN TransactionState = 0 TransactionState_PREPARE TransactionState = 1 - TransactionState_COMMIT TransactionState = 2 - TransactionState_ROLLBACK TransactionState = 3 + TransactionState_ROLLBACK TransactionState = 2 + TransactionState_COMMIT TransactionState = 3 ) // Enum value maps for TransactionState. @@ -437,14 +437,14 @@ var ( TransactionState_name = map[int32]string{ 0: "UNKNOWN", 1: "PREPARE", - 2: "COMMIT", - 3: "ROLLBACK", + 2: "ROLLBACK", + 3: "COMMIT", } TransactionState_value = map[string]int32{ "UNKNOWN": 0, "PREPARE": 1, - "COMMIT": 2, - "ROLLBACK": 3, + "ROLLBACK": 2, + "COMMIT": 3, } ) @@ -6778,8 +6778,8 @@ var file_query_proto_rawDesc = []byte{ 0x4d, 0x10, 0xa2, 0x20, 0x2a, 0x46, 0x0a, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, - 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x02, 0x12, 0x0c, - 0x0a, 0x08, 0x52, 0x4f, 0x4c, 0x4c, 0x42, 0x41, 0x43, 0x4b, 0x10, 0x03, 0x2a, 0x3b, 0x0a, 0x0f, + 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x4f, 0x4c, 0x4c, 0x42, 0x41, 0x43, 0x4b, 0x10, 0x02, + 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x03, 0x2a, 0x3b, 0x0a, 0x0f, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x56, 0x49, 0x45, 0x57, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x53, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x12, diff --git a/go/vt/vttablet/tabletserver/query_executor_test.go b/go/vt/vttablet/tabletserver/query_executor_test.go index 6ec2ffeec92..771d9e3479d 100644 --- a/go/vt/vttablet/tabletserver/query_executor_test.go +++ b/go/vt/vttablet/tabletserver/query_executor_test.go @@ -1703,10 +1703,10 @@ func addQueryExecutorSupportedQueries(db *fakesqldb.DB) { mysql.ShowPrimaryRow("msg", "id"), }, }, - "begin": {}, - "commit": {}, - "rollback": {}, - fmt.Sprintf(sqlReadAllRedo, "_vt", "_vt"): {}, + "begin": {}, + "commit": {}, + "rollback": {}, + fmt.Sprintf(readAllRedo, "_vt", "_vt"): {}, } sidecardb.AddSchemaInitQueries(db, true, sqlparser.NewTestParser()) diff --git a/go/vt/vttablet/tabletserver/tabletserver_test.go b/go/vt/vttablet/tabletserver/tabletserver_test.go index 563ab5e84b3..7ffd201c0a4 100644 --- a/go/vt/vttablet/tabletserver/tabletserver_test.go +++ b/go/vt/vttablet/tabletserver/tabletserver_test.go @@ -2745,10 +2745,10 @@ func addTabletServerSupportedQueries(db *fakesqldb.DB) { Type: sqltypes.Int64, }}, }, - "begin": {}, - "commit": {}, - "rollback": {}, - fmt.Sprintf(sqlReadAllRedo, "_vt", "_vt"): {}, + "begin": {}, + "commit": {}, + "rollback": {}, + fmt.Sprintf(readAllRedo, "_vt", "_vt"): {}, } parser := sqlparser.NewTestParser() sidecardb.AddSchemaInitQueries(db, true, parser) diff --git a/go/vt/vttablet/tabletserver/twopc.go b/go/vt/vttablet/tabletserver/twopc.go index 8d970916697..3db60c6344e 100644 --- a/go/vt/vttablet/tabletserver/twopc.go +++ b/go/vt/vttablet/tabletserver/twopc.go @@ -47,21 +47,27 @@ const ( // DTStateRollback represents the ROLLBACK state for dt_state. DTStateRollback = querypb.TransactionState_ROLLBACK - sqlReadAllRedo = `select t.dtid, t.state, t.time_created, s.statement + readAllRedo = `select t.dtid, t.state, t.time_created, s.statement from %s.redo_state t join %s.redo_statement s on t.dtid = s.dtid order by t.dtid, s.id` - sqlReadAllTransactions = `select t.dtid, t.state, t.time_created, p.keyspace, p.shard + readAllTransactions = `select t.dtid, t.state, t.time_created, p.keyspace, p.shard from %s.dt_state t join %s.dt_participant p on t.dtid = p.dtid order by t.dtid, p.id` - sqlReadAllUnresolvedTransactions = `select t.dtid, t.state, p.keyspace, p.shard + // Ordering by state in descending order to retrieve COMMIT, ROLLBACK, PREPARE in that sequence. + // Resolving COMMIT first is crucial because we need to address transactions where a commit decision has already been made but remains unresolved. + // For transactions with a commit decision, applications are already aware of the outcome and are waiting for the resolution. + // By addressing these first, we ensure atomic commits and improve user experience. For other transactions, the decision is typically to rollback. + readUnresolvedTransactions = `select t.dtid, t.state, p.keyspace, p.shard from %s.dt_state t join %s.dt_participant p on t.dtid = p.dtid where time_created < %a - order by t.dtid, p.id` + order by t.state desc, t.dtid` + + countUnresolvedTransactions = `select count(*) from %s.dt_state where time_created < %a` ) // TwoPC performs 2PC metadata management (MM) functions. @@ -83,9 +89,9 @@ type TwoPC struct { deleteParticipants *sqlparser.ParsedQuery readTransaction *sqlparser.ParsedQuery readParticipants *sqlparser.ParsedQuery - readAbandoned *sqlparser.ParsedQuery readUnresolvedTransactions *sqlparser.ParsedQuery readAllTransactions string + countUnresolvedTransaction *sqlparser.ParsedQuery } // NewTwoPC creates a TwoPC variable. @@ -111,7 +117,7 @@ func (tpc *TwoPC) initializeQueries() { tpc.deleteRedoStmt = sqlparser.BuildParsedQuery( "delete from %s.redo_statement where dtid = %a", dbname, ":dtid") - tpc.readAllRedo = fmt.Sprintf(sqlReadAllRedo, dbname, dbname) + tpc.readAllRedo = fmt.Sprintf(readAllRedo, dbname, dbname) tpc.countUnresolvedRedo = sqlparser.BuildParsedQuery( "select count(*) from %s.redo_state where time_created < %a", dbname, ":time_created") @@ -137,12 +143,11 @@ func (tpc *TwoPC) initializeQueries() { tpc.readParticipants = sqlparser.BuildParsedQuery( "select keyspace, shard from %s.dt_participant where dtid = %a", dbname, ":dtid") - tpc.readAbandoned = sqlparser.BuildParsedQuery( - "select dtid, time_created from %s.dt_state where time_created < %a", - dbname, ":time_created") - tpc.readAllTransactions = fmt.Sprintf(sqlReadAllTransactions, dbname, dbname) - tpc.readUnresolvedTransactions = sqlparser.BuildParsedQuery(sqlReadAllUnresolvedTransactions, + tpc.readAllTransactions = fmt.Sprintf(readAllTransactions, dbname, dbname) + tpc.readUnresolvedTransactions = sqlparser.BuildParsedQuery(readUnresolvedTransactions, dbname, dbname, ":time_created") + tpc.countUnresolvedTransaction = sqlparser.BuildParsedQuery(countUnresolvedTransactions, + dbname, ":time_created") } // Open starts the TwoPC service. @@ -261,8 +266,8 @@ func (tpc *TwoPC) ReadAllRedo(ctx context.Context) (prepared, failed []*tx.Prepa return prepared, failed, nil } -// CountUnresolvedTransactions returns the number of prepared transactions that are still unresolved. -func (tpc *TwoPC) CountUnresolvedTransactions(ctx context.Context, unresolvedTime time.Time) (int64, error) { +// CountUnresolvedRedo returns the number of prepared transactions from dt_redo that are older than the supplied time. +func (tpc *TwoPC) CountUnresolvedRedo(ctx context.Context, unresolvedTime time.Time) (int64, error) { conn, err := tpc.readPool.Get(ctx, nil) if err != nil { return 0, err @@ -520,3 +525,23 @@ func (tpc *TwoPC) UnresolvedTransactions(ctx context.Context, abandonTime time.T return txs, nil } + +// CountUnresolvedTransaction returns the number of transactions from dt_state that are older than the given time. +func (tpc *TwoPC) CountUnresolvedTransaction(ctx context.Context, unresolvedTime time.Time) (int64, error) { + conn, err := tpc.readPool.Get(ctx, nil) + if err != nil { + return 0, err + } + defer conn.Recycle() + + bindVars := map[string]*querypb.BindVariable{ + "time_created": sqltypes.Int64BindVariable(unresolvedTime.UnixNano()), + } + qr, err := tpc.read(ctx, conn.Conn, tpc.countUnresolvedTransaction, bindVars) + if err != nil { + return 0, err + } + // executed query is a scalar aggregation, so we can safely assume that the result is a single row. + v, _ := qr.Rows[0][0].ToCastInt64() + return v, nil +} diff --git a/go/vt/vttablet/tabletserver/tx_engine.go b/go/vt/vttablet/tabletserver/tx_engine.go index 1fd87488cab..4c1a2e1e1d9 100644 --- a/go/vt/vttablet/tabletserver/tx_engine.go +++ b/go/vt/vttablet/tabletserver/tx_engine.go @@ -456,18 +456,18 @@ func (te *TxEngine) startWatchdog() { defer cancel() // Raise alerts on prepares that have been unresolved for too long. - // Use 5x abandonAge to give opportunity for transaction coordinator to resolve these. - count, err := te.twoPC.CountUnresolvedTransactions(ctx, time.Now().Add(-te.abandonAge*5)) + // Use 5x abandonAge to give opportunity for transaction coordinator to resolve these redo logs. + count, err := te.twoPC.CountUnresolvedRedo(ctx, time.Now().Add(-te.abandonAge*5)) if err != nil { - te.env.Stats().InternalErrors.Add("DistributedTransactionWatcherFail", 1) - log.Errorf("Error reading unresolved transactions: %v", err) + te.env.Stats().InternalErrors.Add("RedoWatcherFail", 1) + log.Errorf("Error reading prepared transactions: %v", err) } te.env.Stats().Unresolved.Set("Prepares", count) // Notify lingering distributed transactions. - count, err = te.twoPC.CountUnresolvedTransactions(ctx, time.Now().Add(-te.abandonAge)) + count, err = te.twoPC.CountUnresolvedTransaction(ctx, time.Now().Add(-te.abandonAge)) if err != nil { - te.env.Stats().InternalErrors.Add("DistributedTransactionWatcherFail", 1) + te.env.Stats().InternalErrors.Add("TransactionWatcherFail", 1) log.Errorf("Error reading unresolved transactions: %v", err) return } diff --git a/proto/query.proto b/proto/query.proto index 5253e32a182..99bef7780ac 100644 --- a/proto/query.proto +++ b/proto/query.proto @@ -988,8 +988,8 @@ message StreamHealthResponse { enum TransactionState { UNKNOWN = 0; PREPARE = 1; - COMMIT = 2; - ROLLBACK = 3; + ROLLBACK = 2; + COMMIT = 3; } // TransactionMetadata contains the metadata for a distributed transaction. diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 60eb550ec67..f347f0f33c8 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -42956,8 +42956,8 @@ export namespace query { enum TransactionState { UNKNOWN = 0, PREPARE = 1, - COMMIT = 2, - ROLLBACK = 3 + ROLLBACK = 2, + COMMIT = 3 } /** Properties of a TransactionMetadata. */ diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 99ee1e84900..7cf7fdc61b1 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -104328,15 +104328,15 @@ export const query = $root.query = (() => { * @enum {number} * @property {number} UNKNOWN=0 UNKNOWN value * @property {number} PREPARE=1 PREPARE value - * @property {number} COMMIT=2 COMMIT value - * @property {number} ROLLBACK=3 ROLLBACK value + * @property {number} ROLLBACK=2 ROLLBACK value + * @property {number} COMMIT=3 COMMIT value */ query.TransactionState = (function() { const valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "UNKNOWN"] = 0; values[valuesById[1] = "PREPARE"] = 1; - values[valuesById[2] = "COMMIT"] = 2; - values[valuesById[3] = "ROLLBACK"] = 3; + values[valuesById[2] = "ROLLBACK"] = 2; + values[valuesById[3] = "COMMIT"] = 3; return values; })(); @@ -104577,11 +104577,11 @@ export const query = $root.query = (() => { case 1: message.state = 1; break; - case "COMMIT": + case "ROLLBACK": case 2: message.state = 2; break; - case "ROLLBACK": + case "COMMIT": case 3: message.state = 3; break; From 9ad5ddf3df18bcb631e0ac8ab5977e60587eaa3c Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 11 Jul 2024 21:39:30 +0530 Subject: [PATCH 6/9] ordering unresolved transaction by state, added test. commit > rollback > prepare Signed-off-by: Harshit Gangal --- go/vt/vttablet/endtoend/main_test.go | 7 ++ go/vt/vttablet/endtoend/transaction_test.go | 74 +++++++++++++++++-- .../vttablet/tabletserver/health_streamer.go | 14 ++-- go/vt/vttablet/tabletserver/twopc.go | 8 +- go/vt/vttablet/tabletserver/tx_engine.go | 12 +-- 5 files changed, 92 insertions(+), 23 deletions(-) diff --git a/go/vt/vttablet/endtoend/main_test.go b/go/vt/vttablet/endtoend/main_test.go index 939147cb139..1284f790b93 100644 --- a/go/vt/vttablet/endtoend/main_test.go +++ b/go/vt/vttablet/endtoend/main_test.go @@ -340,6 +340,13 @@ var tableACLConfig = `{ "readers": ["dev"], "writers": ["dev"], "admins": ["dev"] + }, + { + "name": "vitess_twopc", + "table_names_or_prefixes": ["dt_state"], + "readers": ["dev"], + "writers": ["dev"], + "admins": ["dev"] } ] }` diff --git a/go/vt/vttablet/endtoend/transaction_test.go b/go/vt/vttablet/endtoend/transaction_test.go index 296f5c18b56..c3db1485347 100644 --- a/go/vt/vttablet/endtoend/transaction_test.go +++ b/go/vt/vttablet/endtoend/transaction_test.go @@ -540,7 +540,7 @@ func TestMMCommitFlow(t *testing.T) { info.TimeCreated = 0 wantInfo := &querypb.TransactionMetadata{ Dtid: "aa", - State: 2, + State: querypb.TransactionState_COMMIT, Participants: []*querypb.Target{{ Keyspace: "test1", Shard: "0", @@ -593,7 +593,7 @@ func TestMMRollbackFlow(t *testing.T) { info.TimeCreated = 0 wantInfo := &querypb.TransactionMetadata{ Dtid: "aa", - State: 3, + State: querypb.TransactionState_ROLLBACK, Participants: []*querypb.Target{{ Keyspace: "test1", Shard: "0", @@ -612,7 +612,8 @@ func TestMMRollbackFlow(t *testing.T) { require.NoError(t, err) } -func TestWatchdog(t *testing.T) { +func TestTransactionWatcher(t *testing.T) { + t.Skip("TODO: need to update this test") client := framework.NewClient() query := "insert into vitess_test (intval, floatval, charval, binval) " + @@ -743,11 +744,11 @@ func TestUnresolvedTransactions(t *testing.T) { client := framework.NewClient() participants := []*querypb.Target{ - {Keyspace: "ks1", Shard: "-80"}, - {Keyspace: "ks1", Shard: "80-"}, + {Keyspace: "ks1", Shard: "80-c0"}, } err := client.CreateTransaction("dtid01", participants) require.NoError(t, err) + defer client.ConcludeTransaction("dtid01") // expected no transaction to show here, as 1 second not passed. transactions, err := client.UnresolvedTransactions() @@ -766,3 +767,66 @@ func TestUnresolvedTransactions(t *testing.T) { }} utils.MustMatch(t, want, transactions) } + +// TestUnresolvedTransactions tests the UnresolvedTransactions API. +func TestUnresolvedTransactionsOrdering(t *testing.T) { + client := framework.NewClient() + + participants1 := []*querypb.Target{ + {Keyspace: "ks1", Shard: "c0-"}, + {Keyspace: "ks1", Shard: "80-c0"}, + } + participants2 := []*querypb.Target{ + {Keyspace: "ks1", Shard: "-40"}, + {Keyspace: "ks1", Shard: "80-c0"}, + } + participants3 := []*querypb.Target{ + {Keyspace: "ks1", Shard: "c0-"}, + {Keyspace: "ks1", Shard: "-40"}, + } + // prepare state + err := client.CreateTransaction("dtid01", participants1) + require.NoError(t, err) + defer client.ConcludeTransaction("dtid01") + + // commit state + err = client.CreateTransaction("dtid02", participants2) + require.NoError(t, err) + defer client.ConcludeTransaction("dtid02") + _, err = client.Execute( + fmt.Sprintf("update _vt.dt_state set state = %d where dtid = 'dtid02'", querypb.TransactionState_COMMIT.Number()), nil) + require.NoError(t, err) + + // rollback state + err = client.CreateTransaction("dtid03", participants3) + require.NoError(t, err) + defer client.ConcludeTransaction("dtid03") + _, err = client.Execute( + fmt.Sprintf("update _vt.dt_state set state = %d where dtid = 'dtid03'", querypb.TransactionState_ROLLBACK.Number()), nil) + require.NoError(t, err) + + // expected no transaction to show here, as 1 second not passed. + transactions, err := client.UnresolvedTransactions() + require.NoError(t, err) + require.Empty(t, transactions) + + // abandon age is 1 second. + time.Sleep(2 * time.Second) + + transactions, err = client.UnresolvedTransactions() + require.NoError(t, err) + want := []*querypb.TransactionMetadata{{ + Dtid: "dtid02", + State: querypb.TransactionState_COMMIT, + Participants: participants2, + }, { + Dtid: "dtid03", + State: querypb.TransactionState_ROLLBACK, + Participants: participants3, + }, { + Dtid: "dtid01", + State: querypb.TransactionState_PREPARE, + Participants: participants1, + }} + utils.MustMatch(t, want, transactions) +} diff --git a/go/vt/vttablet/tabletserver/health_streamer.go b/go/vt/vttablet/tabletserver/health_streamer.go index 02e4f1a3291..cfc5ea5e974 100644 --- a/go/vt/vttablet/tabletserver/health_streamer.go +++ b/go/vt/vttablet/tabletserver/health_streamer.go @@ -287,14 +287,12 @@ func (hs *healthStreamer) MakePrimary(serving bool) { hs.isServingPrimary = serving // We register for notifications from the schema Engine only when schema tracking is enabled, // and we are going to a serving primary state. - if serving { - if hs.signalWhenSchemaChange { - hs.se.RegisterNotifier("healthStreamer", func(full map[string]*schema.Table, created, altered, dropped []*schema.Table, udfsChanged bool) { - if err := hs.reload(created, altered, dropped, udfsChanged); err != nil { - log.Errorf("periodic schema reload failed in health stream: %v", err) - } - }, false) - } + if serving && hs.signalWhenSchemaChange { + hs.se.RegisterNotifier("healthStreamer", func(full map[string]*schema.Table, created, altered, dropped []*schema.Table, udfsChanged bool) { + if err := hs.reload(created, altered, dropped, udfsChanged); err != nil { + log.Errorf("periodic schema reload failed in health stream: %v", err) + } + }, false) } } diff --git a/go/vt/vttablet/tabletserver/twopc.go b/go/vt/vttablet/tabletserver/twopc.go index 3db60c6344e..fff6d4b0cd8 100644 --- a/go/vt/vttablet/tabletserver/twopc.go +++ b/go/vt/vttablet/tabletserver/twopc.go @@ -266,7 +266,7 @@ func (tpc *TwoPC) ReadAllRedo(ctx context.Context) (prepared, failed []*tx.Prepa return prepared, failed, nil } -// CountUnresolvedRedo returns the number of prepared transactions from dt_redo that are older than the supplied time. +// CountUnresolvedRedo returns the number of prepared transaction recovery log that are older than the supplied time. func (tpc *TwoPC) CountUnresolvedRedo(ctx context.Context, unresolvedTime time.Time) (int64, error) { conn, err := tpc.readPool.Get(ctx, nil) if err != nil { @@ -374,7 +374,7 @@ func (tpc *TwoPC) ReadTransaction(ctx context.Context, dtid string) (*querypb.Tr return nil, vterrors.Wrapf(err, "error parsing state for dtid %s", dtid) } result.State = querypb.TransactionState(st) - if result.State < querypb.TransactionState_PREPARE || result.State > querypb.TransactionState_ROLLBACK { + if result.State < querypb.TransactionState_PREPARE || result.State > querypb.TransactionState_COMMIT { return nil, fmt.Errorf("unexpected state for dtid %s: %v", dtid, result.State) } // A failure in time parsing will show up as a very old time, @@ -427,7 +427,7 @@ func (tpc *TwoPC) ReadAllTransactions(ctx context.Context) ([]*tx.DistributedTx, log.Errorf("Error parsing state for dtid %s: %v.", dtid, err) } protostate := querypb.TransactionState(st) - if protostate < querypb.TransactionState_UNKNOWN || protostate > querypb.TransactionState_ROLLBACK { + if protostate < querypb.TransactionState_PREPARE || protostate > querypb.TransactionState_COMMIT { log.Errorf("Unexpected state for dtid %s: %v.", dtid, protostate) } curTx = &tx.DistributedTx{ @@ -526,7 +526,7 @@ func (tpc *TwoPC) UnresolvedTransactions(ctx context.Context, abandonTime time.T return txs, nil } -// CountUnresolvedTransaction returns the number of transactions from dt_state that are older than the given time. +// CountUnresolvedTransaction returns the number of transaction record that are older than the given time. func (tpc *TwoPC) CountUnresolvedTransaction(ctx context.Context, unresolvedTime time.Time) (int64, error) { conn, err := tpc.readPool.Get(ctx, nil) if err != nil { diff --git a/go/vt/vttablet/tabletserver/tx_engine.go b/go/vt/vttablet/tabletserver/tx_engine.go index 4c1a2e1e1d9..57c6ff1fd64 100644 --- a/go/vt/vttablet/tabletserver/tx_engine.go +++ b/go/vt/vttablet/tabletserver/tx_engine.go @@ -176,7 +176,7 @@ func (te *TxEngine) transition(state txEngineState) { te.env.Stats().InternalErrors.Add("TwopcResurrection", 1) log.Errorf("Could not prepare transactions: %v", err) } - te.startWatchdog() + te.startTransactionWatcher() }() } } @@ -307,7 +307,7 @@ func (te *TxEngine) shutdownLocked() { // Shut down functions are idempotent. // No need to check if 2pc is enabled. log.Infof("TxEngine - stop watchdog") - te.stopWatchdog() + te.stopTransactionWatcher() poolEmpty := make(chan bool) rollbackDone := make(chan bool) @@ -448,9 +448,9 @@ func (te *TxEngine) rollbackPrepared() { } } -// startWatchdog starts the watchdog goroutine, which looks for abandoned +// startTransactionWatcher starts the watchdog goroutine, which looks for abandoned // transactions and calls the notifier on them. -func (te *TxEngine) startWatchdog() { +func (te *TxEngine) startTransactionWatcher() { te.ticks.Start(func() { ctx, cancel := context.WithTimeout(tabletenv.LocalContext(), te.abandonAge/4) defer cancel() @@ -477,8 +477,8 @@ func (te *TxEngine) startWatchdog() { }) } -// stopWatchdog stops the watchdog goroutine. -func (te *TxEngine) stopWatchdog() { +// stopTransactionWatcher stops the watchdog goroutine. +func (te *TxEngine) stopTransactionWatcher() { te.ticks.Stop() } From e9e3626789a6c78ca07feeb3e247243f33787265 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Jul 2024 17:50:27 +0530 Subject: [PATCH 7/9] test: update transaction notifier test Signed-off-by: Harshit Gangal --- .../vttablet/tabletserver/dt_executor_test.go | 54 +++++-------------- go/vt/vttablet/tabletserver/twopc_test.go | 8 +-- 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/go/vt/vttablet/tabletserver/dt_executor_test.go b/go/vt/vttablet/tabletserver/dt_executor_test.go index 6637cc83841..42f3b56034a 100644 --- a/go/vt/vttablet/tabletserver/dt_executor_test.go +++ b/go/vt/vttablet/tabletserver/dt_executor_test.go @@ -31,8 +31,6 @@ import ( "vitess.io/vitess/go/mysql/fakesqldb" "vitess.io/vitess/go/sqltypes" - "vitess.io/vitess/go/vt/vtgate/fakerpcvtgateconn" - "vitess.io/vitess/go/vt/vtgate/vtgateconn" "vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv" querypb "vitess.io/vitess/go/vt/proto/query" @@ -449,51 +447,27 @@ func TestExecutorReadAllTransactions(t *testing.T) { } } -// These vars and types are used only for TestExecutorResolveTransaction -var dtidCh = make(chan string) - -type FakeVTGateConn struct { - fakerpcvtgateconn.FakeVTGateConn -} - -func (conn *FakeVTGateConn) ResolveTransaction(ctx context.Context, dtid string) error { - dtidCh <- dtid - return nil -} - func TestExecutorResolveTransaction(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - protocol := "resolveTest" - oldValue := vtgateconn.GetVTGateProtocol() - vtgateconn.SetVTGateProtocol(protocol) - defer func() { - vtgateconn.SetVTGateProtocol(oldValue) - }() - vtgateconn.RegisterDialer(protocol, func(context.Context, string) (vtgateconn.Impl, error) { - return &FakeVTGateConn{ - FakeVTGateConn: fakerpcvtgateconn.FakeVTGateConn{}, - }, nil - }) + _, tsv, db := newShortAgeExecutor(t, ctx) defer db.Close() defer tsv.StopService() - want := "aa" db.AddQueryPattern( - "select dtid, time_created from _vt\\.dt_state where time_created.*", - &sqltypes.Result{ - Fields: []*querypb.Field{ - {Type: sqltypes.VarChar}, - {Type: sqltypes.Int64}, - }, - Rows: [][]sqltypes.Value{{ - sqltypes.NewVarBinary(want), - sqltypes.NewVarBinary("1"), - }}, - }) - got := <-dtidCh - if got != want { - t.Errorf("ResolveTransaction: %s, want %s", got, want) + "select count\\(\\*\\) from _vt\\.redo_state where time_created.*", + sqltypes.MakeTestResult(sqltypes.MakeTestFields("count(*)", "int64"), "0")) + db.AddQueryPattern( + "select count\\(\\*\\) from _vt\\.dt_state where time_created.*", + sqltypes.MakeTestResult(sqltypes.MakeTestFields("count(*)", "int64"), "1")) + notifyCh := make(chan any) + tsv.te.dxNotify = func() { + notifyCh <- nil + } + select { + case <-notifyCh: + case <-time.After(1 * time.Second): + t.Error("unresolved transaction notifier not called") } } diff --git a/go/vt/vttablet/tabletserver/twopc_test.go b/go/vt/vttablet/tabletserver/twopc_test.go index af67f644830..f0fa77e0ff8 100644 --- a/go/vt/vttablet/tabletserver/twopc_test.go +++ b/go/vt/vttablet/tabletserver/twopc_test.go @@ -437,10 +437,10 @@ func TestUnresolvedTransactions(t *testing.T) { unresolvedTx: sqltypes.MakeTestResult( sqltypes.MakeTestFields("dtid|state|keyspace|shard", "VARBINARY|INT64|VARCHAR|VARCHAR"), - "dtid0|2|ks01|shard01", - "dtid0|2|ks01|shard02", - "dtid1|3|ks02|shard03", - "dtid1|3|ks01|shard02"), + "dtid0|3|ks01|shard01", + "dtid0|3|ks01|shard02", + "dtid1|2|ks02|shard03", + "dtid1|2|ks01|shard02"), expectedTx: []*querypb.TransactionMetadata{{ Dtid: "dtid0", State: querypb.TransactionState_COMMIT, From b24906be3dd96164ffdeba063d355a4a9103745c Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Jul 2024 20:40:28 +0530 Subject: [PATCH 8/9] test: added transaction watcher tests Signed-off-by: Harshit Gangal --- go/vt/vttablet/endtoend/framework/server.go | 26 -------- go/vt/vttablet/endtoend/transaction_test.go | 66 ++++++++++--------- .../vttablet/tabletserver/dt_executor_test.go | 20 +++++- 3 files changed, 53 insertions(+), 59 deletions(-) diff --git a/go/vt/vttablet/endtoend/framework/server.go b/go/vt/vttablet/endtoend/framework/server.go index 07c4f0424ac..2cd3ccc354c 100644 --- a/go/vt/vttablet/endtoend/framework/server.go +++ b/go/vt/vttablet/endtoend/framework/server.go @@ -35,8 +35,6 @@ import ( "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/vt/dbconfigs" - "vitess.io/vitess/go/vt/vtgate/fakerpcvtgateconn" - "vitess.io/vitess/go/vt/vtgate/vtgateconn" "vitess.io/vitess/go/vt/vttablet/tabletserver" "vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv" @@ -51,8 +49,6 @@ var ( Server *tabletserver.TabletServer // ServerAddress is the http URL for the server. ServerAddress string - // ResolveChan is the channel that sends dtids that are to be resolved. - ResolveChan = make(chan string, 1) // TopoServer is the topology for the server TopoServer *topo.Server ) @@ -61,15 +57,6 @@ var ( // all the global variables. This function should only be called // once at the beginning of the test. func StartCustomServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnParams, dbName string, cfg *tabletenv.TabletConfig) error { - // Setup a fake vtgate server. - protocol := "resolveTest" - vtgateconn.SetVTGateProtocol(protocol) - vtgateconn.RegisterDialer(protocol, func(context.Context, string) (vtgateconn.Impl, error) { - return &txResolver{ - FakeVTGateConn: fakerpcvtgateconn.FakeVTGateConn{}, - }, nil - }) - dbcfgs := dbconfigs.NewTestDBConfigs(connParams, connAppDebugParams, dbName) Target = &querypb.Target{ @@ -137,16 +124,3 @@ func StartServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnP func StopServer() { Server.StopService() } - -// txResolver transmits dtids to be resolved through ResolveChan. -type txResolver struct { - fakerpcvtgateconn.FakeVTGateConn -} - -func (conn *txResolver) ResolveTransaction(ctx context.Context, dtid string) error { - select { - case ResolveChan <- dtid: - default: - } - return nil -} diff --git a/go/vt/vttablet/endtoend/transaction_test.go b/go/vt/vttablet/endtoend/transaction_test.go index c3db1485347..915b56f993e 100644 --- a/go/vt/vttablet/endtoend/transaction_test.go +++ b/go/vt/vttablet/endtoend/transaction_test.go @@ -612,8 +612,8 @@ func TestMMRollbackFlow(t *testing.T) { require.NoError(t, err) } -func TestTransactionWatcher(t *testing.T) { - t.Skip("TODO: need to update this test") +// TestTransactionWatcherSignal test that unresolved transaction signal is received via health stream. +func TestTransactionWatcherSignal(t *testing.T) { client := framework.NewClient() query := "insert into vitess_test (intval, floatval, charval, binval) " + @@ -623,44 +623,50 @@ func TestTransactionWatcher(t *testing.T) { _, err = client.Execute(query, nil) require.NoError(t, err) - start := time.Now() - err = client.CreateTransaction("aa", []*querypb.Target{{ - Keyspace: "test1", - Shard: "0", - }, { - Keyspace: "test2", - Shard: "1", - }}) + ch := make(chan any) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go func() { + err := client.StreamHealthWithContext(ctx, func(shr *querypb.StreamHealthResponse) error { + if shr.RealtimeStats.TxUnresolved { + ch <- true + } + return nil + }) + require.NoError(t, err) + }() + + err = client.CreateTransaction("aa", []*querypb.Target{ + {Keyspace: "test1", Shard: "0"}, + {Keyspace: "test2", Shard: "1"}}) require.NoError(t, err) - // The watchdog should kick in after 1 second. - dtid := <-framework.ResolveChan - if dtid != "aa" { - t.Errorf("dtid: %s, want aa", dtid) - } - diff := time.Since(start) - if diff < 1*time.Second { - t.Errorf("diff: %v, want greater than 1s", diff) + // wait for unresolved transaction signal + select { + case <-ch: + case <-time.After(2 * time.Second): + t.Fatal("timed out waiting for transaction watcher signal") } err = client.SetRollback("aa", 0) require.NoError(t, err) + + // still should receive unresolved transaction signal + select { + case <-ch: + case <-time.After(2 * time.Second): + t.Fatal("timed out waiting for transaction watcher signal") + } + err = client.ConcludeTransaction("aa") require.NoError(t, err) - // Make sure the watchdog stops sending messages. - // Check twice. Sometimes, a race can still cause - // a stray message. - dtid = "" - for i := 0; i < 2; i++ { - select { - case dtid = <-framework.ResolveChan: - continue - case <-time.After(2 * time.Second): - return - } + // transaction watcher should stop sending singal now. + select { + case <-ch: + t.Fatal("unexpected signal for unresolved transaction") + case <-time.After(2 * time.Second): } - t.Errorf("Unexpected message: %s", dtid) } func TestUnresolvedTracking(t *testing.T) { diff --git a/go/vt/vttablet/tabletserver/dt_executor_test.go b/go/vt/vttablet/tabletserver/dt_executor_test.go index 42f3b56034a..448dd63bf5a 100644 --- a/go/vt/vttablet/tabletserver/dt_executor_test.go +++ b/go/vt/vttablet/tabletserver/dt_executor_test.go @@ -447,7 +447,9 @@ func TestExecutorReadAllTransactions(t *testing.T) { } } -func TestExecutorResolveTransaction(t *testing.T) { +// TestTransactionNotifier tests that the transaction notifier is called +// when a transaction watcher receives unresolved transaction count more than zero. +func TestTransactionNotifier(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -457,17 +459,29 @@ func TestExecutorResolveTransaction(t *testing.T) { db.AddQueryPattern( "select count\\(\\*\\) from _vt\\.redo_state where time_created.*", sqltypes.MakeTestResult(sqltypes.MakeTestFields("count(*)", "int64"), "0")) + + // zero unresolved transactions db.AddQueryPattern( "select count\\(\\*\\) from _vt\\.dt_state where time_created.*", - sqltypes.MakeTestResult(sqltypes.MakeTestFields("count(*)", "int64"), "1")) + sqltypes.MakeTestResult(sqltypes.MakeTestFields("count(*)", "int64"), "0")) notifyCh := make(chan any) tsv.te.dxNotify = func() { notifyCh <- nil } select { + case <-notifyCh: + t.Error("unresolved transaction notifier call unexpected") + case <-time.After(1 * time.Second): + } + + // non zero unresolved transactions + db.AddQueryPattern( + "select count\\(\\*\\) from _vt\\.dt_state where time_created.*", + sqltypes.MakeTestResult(sqltypes.MakeTestFields("count(*)", "int64"), "1")) + select { case <-notifyCh: case <-time.After(1 * time.Second): - t.Error("unresolved transaction notifier not called") + t.Error("unresolved transaction notifier expected but not received") } } From b206eb7d0ff7a3634a1a99e074a50ad0736fec23 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Mon, 15 Jul 2024 10:34:57 +0200 Subject: [PATCH 9/9] extract checking into test helper Signed-off-by: Andres Taylor --- go/vt/vttablet/endtoend/transaction_test.go | 57 +++++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/go/vt/vttablet/endtoend/transaction_test.go b/go/vt/vttablet/endtoend/transaction_test.go index 915b56f993e..94453dd70e7 100644 --- a/go/vt/vttablet/endtoend/transaction_test.go +++ b/go/vt/vttablet/endtoend/transaction_test.go @@ -612,6 +612,41 @@ func TestMMRollbackFlow(t *testing.T) { require.NoError(t, err) } +type AsyncChecker struct { + t *testing.T + ch chan bool +} + +func newAsyncChecker(t *testing.T) *AsyncChecker { + return &AsyncChecker{ + t: t, + ch: make(chan bool), + } +} + +func (ac *AsyncChecker) check() { + ac.ch <- true +} + +func (ac *AsyncChecker) shouldNotify(timeout time.Duration, message string) { + select { + case <-ac.ch: + // notified, all is well + case <-time.After(timeout): + // timed out waiting for notification + ac.t.Error(message) + } +} +func (ac *AsyncChecker) shouldNotNotify(timeout time.Duration, message string) { + select { + case <-ac.ch: + // notified - not expected + ac.t.Error(message) + case <-time.After(timeout): + // timed out waiting for notification, which is expected + } +} + // TestTransactionWatcherSignal test that unresolved transaction signal is received via health stream. func TestTransactionWatcherSignal(t *testing.T) { client := framework.NewClient() @@ -623,13 +658,13 @@ func TestTransactionWatcherSignal(t *testing.T) { _, err = client.Execute(query, nil) require.NoError(t, err) - ch := make(chan any) + ch := newAsyncChecker(t) ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { err := client.StreamHealthWithContext(ctx, func(shr *querypb.StreamHealthResponse) error { if shr.RealtimeStats.TxUnresolved { - ch <- true + ch.check() } return nil }) @@ -642,31 +677,19 @@ func TestTransactionWatcherSignal(t *testing.T) { require.NoError(t, err) // wait for unresolved transaction signal - select { - case <-ch: - case <-time.After(2 * time.Second): - t.Fatal("timed out waiting for transaction watcher signal") - } + ch.shouldNotify(2*time.Second, "timed out waiting for transaction watcher signal") err = client.SetRollback("aa", 0) require.NoError(t, err) // still should receive unresolved transaction signal - select { - case <-ch: - case <-time.After(2 * time.Second): - t.Fatal("timed out waiting for transaction watcher signal") - } + ch.shouldNotify(2*time.Second, "timed out waiting for transaction watcher signal") err = client.ConcludeTransaction("aa") require.NoError(t, err) // transaction watcher should stop sending singal now. - select { - case <-ch: - t.Fatal("unexpected signal for unresolved transaction") - case <-time.After(2 * time.Second): - } + ch.shouldNotNotify(2*time.Second, "unexpected signal for resolved transaction") } func TestUnresolvedTracking(t *testing.T) {