From 2721fdbf677c4de4b857f5a9a2ada1e8e1d3f98e Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 13:49:21 -0400 Subject: [PATCH 01/14] This effectively reverts 65226ad1d77629fe29e852393a19250a9a910024 It was NOT backwards compatible. Signed-off-by: Matt Lord --- go/mysql/replication_status.go | 32 +++- .../replicationdata/replicationdata.pb.go | 148 ++++++++++-------- .../replicationdata_vtproto.pb.go | 119 +++++++++----- go/vt/vtadmin/cluster/cluster_test.go | 37 +++-- .../reparentutil/emergency_reparenter_test.go | 44 +++--- go/vt/vtctl/reparentutil/replication.go | 2 +- go/vt/vtctl/reparentutil/replication_test.go | 16 +- go/vt/vttablet/tmrpctest/test_tm_rpc.go | 6 +- proto/replicationdata.proto | 10 +- web/vtadmin/src/proto/vtadmin.d.ts | 26 +-- web/vtadmin/src/proto/vtadmin.js | 98 +++++++----- 11 files changed, 315 insertions(+), 223 deletions(-) diff --git a/go/mysql/replication_status.go b/go/mysql/replication_status.go index 114f4e7ac51..201c88a426c 100644 --- a/go/mysql/replication_status.go +++ b/go/mysql/replication_status.go @@ -75,7 +75,7 @@ func (s *ReplicationStatus) SQLHealthy() bool { // ReplicationStatusToProto translates a Status to proto3. func ReplicationStatusToProto(s ReplicationStatus) *replicationdatapb.Status { - return &replicationdatapb.Status{ + replstatus := replicationdatapb.Status{ Position: EncodePosition(s.Position), RelayLogPosition: EncodePosition(s.RelayLogPosition), FilePosition: EncodePosition(s.FilePosition), @@ -86,11 +86,18 @@ func ReplicationStatusToProto(s ReplicationStatus) *replicationdatapb.Status { SourcePort: int32(s.SourcePort), ConnectRetry: int32(s.ConnectRetry), SourceUuid: s.SourceUUID.String(), - IoState: int32(s.IOState), LastIoError: s.LastIOError, - SqlState: int32(s.SQLState), LastSqlError: s.LastSQLError, } + if s.IOState == ReplicationStateRunning { + replstatus.IoThreadRunning = true + } else if s.IOState == ReplicationStateConnecting { + replstatus.IoThreadConnecting = true + } + if s.SQLState == ReplicationStateRunning { + replstatus.SqlThreadRunning = true + } + return &replstatus } // ProtoToReplicationStatus translates a proto Status, or panics. @@ -118,7 +125,7 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { panic(vterrors.Wrapf(err, "cannot decode SourceUUID")) } } - return ReplicationStatus{ + replstatus := ReplicationStatus{ Position: pos, RelayLogPosition: relayPos, FilePosition: filePos, @@ -129,11 +136,20 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { SourcePort: int(s.SourcePort), ConnectRetry: int(s.ConnectRetry), SourceUUID: sid, - IOState: ReplicationState(s.IoState), - LastIOError: s.LastIoError, - SQLState: ReplicationState(s.SqlState), - LastSQLError: s.LastSqlError, } + if s.IoThreadRunning { + replstatus.IOState = ReplicationStateRunning + } else if s.IoThreadConnecting { + replstatus.IOState = ReplicationStateConnecting + } else { + replstatus.IOState = ReplicationStateStopped + } + if s.SqlThreadRunning { + replstatus.SQLState = ReplicationStateRunning + } else { + replstatus.SQLState = ReplicationStateStopped + } + return replstatus } // FindErrantGTIDs can be used to find errant GTIDs in the receiver's relay log, by comparing it against all known replicas, diff --git a/go/vt/proto/replicationdata/replicationdata.pb.go b/go/vt/proto/replicationdata/replicationdata.pb.go index 1dd0142248e..97d782b90c5 100644 --- a/go/vt/proto/replicationdata/replicationdata.pb.go +++ b/go/vt/proto/replicationdata/replicationdata.pb.go @@ -92,6 +92,8 @@ type Status struct { unknownFields protoimpl.UnknownFields Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + IoThreadRunning bool `protobuf:"varint,2,opt,name=io_thread_running,json=ioThreadRunning,proto3" json:"io_thread_running,omitempty"` + SqlThreadRunning bool `protobuf:"varint,3,opt,name=sql_thread_running,json=sqlThreadRunning,proto3" json:"sql_thread_running,omitempty"` ReplicationLagSeconds uint32 `protobuf:"varint,4,opt,name=replication_lag_seconds,json=replicationLagSeconds,proto3" json:"replication_lag_seconds,omitempty"` SourceHost string `protobuf:"bytes,5,opt,name=source_host,json=sourceHost,proto3" json:"source_host,omitempty"` SourcePort int32 `protobuf:"varint,6,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty"` @@ -102,10 +104,9 @@ type Status struct { FileRelayLogPosition string `protobuf:"bytes,10,opt,name=file_relay_log_position,json=fileRelayLogPosition,proto3" json:"file_relay_log_position,omitempty"` SourceServerId uint32 `protobuf:"varint,11,opt,name=source_server_id,json=sourceServerId,proto3" json:"source_server_id,omitempty"` SourceUuid string `protobuf:"bytes,12,opt,name=source_uuid,json=sourceUuid,proto3" json:"source_uuid,omitempty"` - IoState int32 `protobuf:"varint,13,opt,name=io_state,json=ioState,proto3" json:"io_state,omitempty"` + IoThreadConnecting bool `protobuf:"varint,13,opt,name=io_thread_connecting,json=ioThreadConnecting,proto3" json:"io_thread_connecting,omitempty"` LastIoError string `protobuf:"bytes,14,opt,name=last_io_error,json=lastIoError,proto3" json:"last_io_error,omitempty"` - SqlState int32 `protobuf:"varint,15,opt,name=sql_state,json=sqlState,proto3" json:"sql_state,omitempty"` - LastSqlError string `protobuf:"bytes,16,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` + LastSqlError string `protobuf:"bytes,15,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` } func (x *Status) Reset() { @@ -147,6 +148,20 @@ func (x *Status) GetPosition() string { return "" } +func (x *Status) GetIoThreadRunning() bool { + if x != nil { + return x.IoThreadRunning + } + return false +} + +func (x *Status) GetSqlThreadRunning() bool { + if x != nil { + return x.SqlThreadRunning + } + return false +} + func (x *Status) GetReplicationLagSeconds() uint32 { if x != nil { return x.ReplicationLagSeconds @@ -210,11 +225,11 @@ func (x *Status) GetSourceUuid() string { return "" } -func (x *Status) GetIoState() int32 { +func (x *Status) GetIoThreadConnecting() bool { if x != nil { - return x.IoState + return x.IoThreadConnecting } - return 0 + return false } func (x *Status) GetLastIoError() string { @@ -224,13 +239,6 @@ func (x *Status) GetLastIoError() string { return "" } -func (x *Status) GetSqlState() int32 { - if x != nil { - return x.SqlState - } - return 0 -} - func (x *Status) GetLastSqlError() string { if x != nil { return x.LastSqlError @@ -356,64 +364,66 @@ var File_replicationdata_proto protoreflect.FileDescriptor var file_replicationdata_proto_rawDesc = []byte{ 0x0a, 0x15, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x22, 0xcd, 0x04, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x22, 0xee, 0x04, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x2a, 0x0a, 0x11, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6e, + 0x6e, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6f, 0x54, 0x68, + 0x72, 0x65, 0x61, 0x64, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x2c, 0x0a, 0x12, 0x73, + 0x71, 0x6c, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, + 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x71, 0x6c, 0x54, 0x68, 0x72, 0x65, + 0x61, 0x64, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x36, 0x0a, 0x17, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x61, 0x67, 0x5f, 0x73, 0x65, 0x63, + 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x15, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x67, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, + 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x73, 0x74, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x6f, + 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, + 0x6f, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, + 0x65, 0x74, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x61, + 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x4c, 0x6f, 0x67, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, + 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x17, 0x66, + 0x69, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x69, + 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x75, 0x69, 0x64, 0x12, 0x30, 0x0a, + 0x14, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x69, 0x6f, 0x54, + 0x68, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x12, + 0x22, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6f, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6f, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, + 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, + 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x62, 0x65, 0x66, + 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x61, 0x66, 0x74, + 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x36, 0x0a, 0x17, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, - 0x61, 0x67, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x15, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x67, - 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x74, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x2c, - 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x72, 0x65, 0x6c, 0x61, - 0x79, 0x4c, 0x6f, 0x67, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, - 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x35, 0x0a, 0x17, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, - 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x14, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4c, 0x6f, 0x67, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x75, 0x75, 0x69, - 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, - 0x75, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, - 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x69, 0x6f, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x22, - 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6f, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, - 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6f, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x71, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x71, 0x6c, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, 0x08, 0x03, 0x10, - 0x04, 0x52, 0x11, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6e, - 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x73, 0x71, 0x6c, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, - 0x5f, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x70, - 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, - 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, - 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, - 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x2a, 0x3b, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x4f, - 0x41, 0x4e, 0x44, 0x53, 0x51, 0x4c, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x10, 0x00, 0x12, 0x10, - 0x0a, 0x0c, 0x49, 0x4f, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x01, - 0x42, 0x2e, 0x5a, 0x2c, 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, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3b, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x49, + 0x4f, 0x41, 0x4e, 0x44, 0x53, 0x51, 0x4c, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x10, 0x00, 0x12, + 0x10, 0x0a, 0x0c, 0x49, 0x4f, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, + 0x01, 0x42, 0x2e, 0x5a, 0x2c, 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, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, + 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go index 252150801c7..3bced0530ef 100644 --- a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go +++ b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go @@ -53,14 +53,7 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { copy(dAtA[i:], m.LastSqlError) i = encodeVarint(dAtA, i, uint64(len(m.LastSqlError))) i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - } - if m.SqlState != 0 { - i = encodeVarint(dAtA, i, uint64(m.SqlState)) - i-- - dAtA[i] = 0x78 + dAtA[i] = 0x7a } if len(m.LastIoError) > 0 { i -= len(m.LastIoError) @@ -69,8 +62,13 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i-- dAtA[i] = 0x72 } - if m.IoState != 0 { - i = encodeVarint(dAtA, i, uint64(m.IoState)) + if m.IoThreadConnecting { + i-- + if m.IoThreadConnecting { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } i-- dAtA[i] = 0x68 } @@ -129,6 +127,26 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } + if m.SqlThreadRunning { + i-- + if m.SqlThreadRunning { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.IoThreadRunning { + i-- + if m.IoThreadRunning { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } if len(m.Position) > 0 { i -= len(m.Position) copy(dAtA[i:], m.Position) @@ -260,6 +278,12 @@ func (m *Status) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } + if m.IoThreadRunning { + n += 2 + } + if m.SqlThreadRunning { + n += 2 + } if m.ReplicationLagSeconds != 0 { n += 1 + sov(uint64(m.ReplicationLagSeconds)) } @@ -292,19 +316,16 @@ func (m *Status) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.IoState != 0 { - n += 1 + sov(uint64(m.IoState)) + if m.IoThreadConnecting { + n += 2 } l = len(m.LastIoError) if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.SqlState != 0 { - n += 1 + sov(uint64(m.SqlState)) - } l = len(m.LastSqlError) if l > 0 { - n += 2 + l + sov(uint64(l)) + n += 1 + l + sov(uint64(l)) } if m.unknownFields != nil { n += len(m.unknownFields) @@ -419,6 +440,46 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } m.Position = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IoThreadRunning", 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.IoThreadRunning = bool(v != 0) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SqlThreadRunning", 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.SqlThreadRunning = bool(v != 0) case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ReplicationLagSeconds", wireType) @@ -657,9 +718,9 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { iNdEx = postIndex case 13: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IoState", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IoThreadConnecting", wireType) } - m.IoState = 0 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -669,11 +730,12 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.IoState |= int32(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } + m.IoThreadConnecting = bool(v != 0) case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastIoError", wireType) @@ -707,25 +769,6 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { m.LastIoError = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 15: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SqlState", wireType) - } - m.SqlState = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SqlState |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 16: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastSqlError", wireType) } diff --git a/go/vt/vtadmin/cluster/cluster_test.go b/go/vt/vtadmin/cluster/cluster_test.go index 38293064cc2..aa9d9d5b646 100644 --- a/go/vt/vtadmin/cluster/cluster_test.go +++ b/go/vt/vtadmin/cluster/cluster_test.go @@ -29,7 +29,6 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/util/sets" - "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/protoutil" "vitess.io/vitess/go/test/utils" "vitess.io/vitess/go/vt/topo" @@ -2427,19 +2426,19 @@ func TestGetShardReplicationPositions(t *testing.T) { Response: &vtctldatapb.ShardReplicationPositionsResponse{ ReplicationStatuses: map[string]*replicationdatapb.Status{ "zone1-001": { - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoThreadRunning: false, + SqlThreadRunning: false, + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-002": { // Note: in reality other fields will be set on replicating hosts as well, but this is sufficient to illustrate in the testing. - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoThreadRunning: true, + SqlThreadRunning: true, + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-003": { - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoThreadRunning: true, + SqlThreadRunning: true, + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, }, TabletMap: map[string]*topodatapb.Tablet{ @@ -2490,19 +2489,19 @@ func TestGetShardReplicationPositions(t *testing.T) { PositionInfo: &vtctldatapb.ShardReplicationPositionsResponse{ ReplicationStatuses: map[string]*replicationdatapb.Status{ "zone1-001": { - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoThreadRunning: false, + SqlThreadRunning: false, + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-002": { - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoThreadRunning: true, + SqlThreadRunning: true, + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-003": { - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoThreadRunning: true, + SqlThreadRunning: true, + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, }, TabletMap: map[string]*topodatapb.Tablet{ diff --git a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go index 746c3c70d88..9055588bd44 100644 --- a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go +++ b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go @@ -2038,14 +2038,14 @@ func TestEmergencyReparenter_promoteNewPrimary(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: false, + SqlThreadRunning: false, }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, }, @@ -2416,14 +2416,14 @@ func TestEmergencyReparenter_promoteNewPrimary(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: false, + SqlThreadRunning: false, }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, }, @@ -3229,14 +3229,14 @@ func TestEmergencyReparenter_reparentReplicas(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: false, + SqlThreadRunning: false, }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, }, @@ -3622,14 +3622,14 @@ func TestEmergencyReparenter_promoteIntermediateSource(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: false, + SqlThreadRunning: false, }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, }, @@ -3896,14 +3896,14 @@ func TestEmergencyReparenter_promoteIntermediateSource(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: false, + SqlThreadRunning: false, }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, }, @@ -4242,8 +4242,8 @@ func TestParentContextCancelled(t *testing.T) { statusMap := map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, } diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index a98053f829e..ca5337bbbfe 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -150,7 +150,7 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) } - return stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning), nil + return stopStatus.Before.IoThreadRunning || stopStatus.Before.SqlThreadRunning, nil } // SetReplicationSource is used to set the replication source on the specified diff --git a/go/vt/vtctl/reparentutil/replication_test.go b/go/vt/vtctl/reparentutil/replication_test.go index 13f25295599..d50c0487769 100644 --- a/go/vt/vtctl/reparentutil/replication_test.go +++ b/go/vt/vtctl/reparentutil/replication_test.go @@ -1098,8 +1098,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "io thread running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: true, + SqlThreadRunning: false, }, }, expected: true, @@ -1109,8 +1109,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "sql thread running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: false, + SqlThreadRunning: true, }, }, expected: true, @@ -1120,8 +1120,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "io and sql threads running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, }, }, expected: true, @@ -1131,8 +1131,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "no replication threads running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoState: int32(mysql.ReplicationStateStopped), - SqlState: int32(mysql.ReplicationStateStopped), + IoThreadRunning: false, + SqlThreadRunning: false, }, }, expected: false, diff --git a/go/vt/vttablet/tmrpctest/test_tm_rpc.go b/go/vt/vttablet/tmrpctest/test_tm_rpc.go index ed0c338868e..9d7531aa551 100644 --- a/go/vt/vttablet/tmrpctest/test_tm_rpc.go +++ b/go/vt/vttablet/tmrpctest/test_tm_rpc.go @@ -25,8 +25,6 @@ import ( "testing" "time" - "vitess.io/vitess/go/mysql" - "context" "google.golang.org/protobuf/proto" @@ -686,8 +684,8 @@ func tmRPCTestExecuteFetchPanic(ctx context.Context, t *testing.T, client tmclie var testReplicationStatus = &replicationdatapb.Status{ Position: "MariaDB/1-345-789", - IoState: int32(mysql.ReplicationStateRunning), - SqlState: int32(mysql.ReplicationStateRunning), + IoThreadRunning: true, + SqlThreadRunning: true, ReplicationLagSeconds: 654, SourceHost: "source.host", SourcePort: 3366, diff --git a/proto/replicationdata.proto b/proto/replicationdata.proto index b6ef28ec119..87a6ea331e7 100644 --- a/proto/replicationdata.proto +++ b/proto/replicationdata.proto @@ -25,9 +25,8 @@ package replicationdata; // flavor-specific command and parsed into a Position and fields. message Status { string position = 1; - // These two fields were removed in Vitess 14 and replaced by the io_state and sql_state fields - reserved 2, 3; - reserved "io_thread_running", "sql_thread_running"; + bool io_thread_running = 2; + bool sql_thread_running = 3; uint32 replication_lag_seconds = 4; string source_host = 5; int32 source_port = 6; @@ -38,10 +37,9 @@ message Status { string file_relay_log_position = 10; uint32 source_server_id = 11; string source_uuid = 12; - int32 io_state = 13; + bool io_thread_connecting = 13; string last_io_error = 14; - int32 sql_state = 15; - string last_sql_error = 16; + string last_sql_error = 15; } // StopReplicationStatus represents the replication status before calling StopReplication, and the replication status collected immediately after diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index f71a6629194..cafafa89ef7 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -26860,6 +26860,12 @@ export namespace replicationdata { /** Status position */ position?: (string|null); + /** Status io_thread_running */ + io_thread_running?: (boolean|null); + + /** Status sql_thread_running */ + sql_thread_running?: (boolean|null); + /** Status replication_lag_seconds */ replication_lag_seconds?: (number|null); @@ -26887,15 +26893,12 @@ export namespace replicationdata { /** Status source_uuid */ source_uuid?: (string|null); - /** Status io_state */ - io_state?: (number|null); + /** Status io_thread_connecting */ + io_thread_connecting?: (boolean|null); /** Status last_io_error */ last_io_error?: (string|null); - /** Status sql_state */ - sql_state?: (number|null); - /** Status last_sql_error */ last_sql_error?: (string|null); } @@ -26912,6 +26915,12 @@ export namespace replicationdata { /** Status position. */ public position: string; + /** Status io_thread_running. */ + public io_thread_running: boolean; + + /** Status sql_thread_running. */ + public sql_thread_running: boolean; + /** Status replication_lag_seconds. */ public replication_lag_seconds: number; @@ -26939,15 +26948,12 @@ export namespace replicationdata { /** Status source_uuid. */ public source_uuid: string; - /** Status io_state. */ - public io_state: number; + /** Status io_thread_connecting. */ + public io_thread_connecting: boolean; /** Status last_io_error. */ public last_io_error: string; - /** Status sql_state. */ - public sql_state: number; - /** Status last_sql_error. */ public last_sql_error: string; diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 647e7fbfc46..61d1b71f9cd 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -63272,6 +63272,8 @@ $root.replicationdata = (function() { * @memberof replicationdata * @interface IStatus * @property {string|null} [position] Status position + * @property {boolean|null} [io_thread_running] Status io_thread_running + * @property {boolean|null} [sql_thread_running] Status sql_thread_running * @property {number|null} [replication_lag_seconds] Status replication_lag_seconds * @property {string|null} [source_host] Status source_host * @property {number|null} [source_port] Status source_port @@ -63281,9 +63283,8 @@ $root.replicationdata = (function() { * @property {string|null} [file_relay_log_position] Status file_relay_log_position * @property {number|null} [source_server_id] Status source_server_id * @property {string|null} [source_uuid] Status source_uuid - * @property {number|null} [io_state] Status io_state + * @property {boolean|null} [io_thread_connecting] Status io_thread_connecting * @property {string|null} [last_io_error] Status last_io_error - * @property {number|null} [sql_state] Status sql_state * @property {string|null} [last_sql_error] Status last_sql_error */ @@ -63310,6 +63311,22 @@ $root.replicationdata = (function() { */ Status.prototype.position = ""; + /** + * Status io_thread_running. + * @member {boolean} io_thread_running + * @memberof replicationdata.Status + * @instance + */ + Status.prototype.io_thread_running = false; + + /** + * Status sql_thread_running. + * @member {boolean} sql_thread_running + * @memberof replicationdata.Status + * @instance + */ + Status.prototype.sql_thread_running = false; + /** * Status replication_lag_seconds. * @member {number} replication_lag_seconds @@ -63383,12 +63400,12 @@ $root.replicationdata = (function() { Status.prototype.source_uuid = ""; /** - * Status io_state. - * @member {number} io_state + * Status io_thread_connecting. + * @member {boolean} io_thread_connecting * @memberof replicationdata.Status * @instance */ - Status.prototype.io_state = 0; + Status.prototype.io_thread_connecting = false; /** * Status last_io_error. @@ -63398,14 +63415,6 @@ $root.replicationdata = (function() { */ Status.prototype.last_io_error = ""; - /** - * Status sql_state. - * @member {number} sql_state - * @memberof replicationdata.Status - * @instance - */ - Status.prototype.sql_state = 0; - /** * Status last_sql_error. * @member {string} last_sql_error @@ -63440,6 +63449,10 @@ $root.replicationdata = (function() { writer = $Writer.create(); if (message.position != null && Object.hasOwnProperty.call(message, "position")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.position); + if (message.io_thread_running != null && Object.hasOwnProperty.call(message, "io_thread_running")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.io_thread_running); + if (message.sql_thread_running != null && Object.hasOwnProperty.call(message, "sql_thread_running")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.sql_thread_running); if (message.replication_lag_seconds != null && Object.hasOwnProperty.call(message, "replication_lag_seconds")) writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.replication_lag_seconds); if (message.source_host != null && Object.hasOwnProperty.call(message, "source_host")) @@ -63458,14 +63471,12 @@ $root.replicationdata = (function() { writer.uint32(/* id 11, wireType 0 =*/88).uint32(message.source_server_id); if (message.source_uuid != null && Object.hasOwnProperty.call(message, "source_uuid")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.source_uuid); - if (message.io_state != null && Object.hasOwnProperty.call(message, "io_state")) - writer.uint32(/* id 13, wireType 0 =*/104).int32(message.io_state); + if (message.io_thread_connecting != null && Object.hasOwnProperty.call(message, "io_thread_connecting")) + writer.uint32(/* id 13, wireType 0 =*/104).bool(message.io_thread_connecting); if (message.last_io_error != null && Object.hasOwnProperty.call(message, "last_io_error")) writer.uint32(/* id 14, wireType 2 =*/114).string(message.last_io_error); - if (message.sql_state != null && Object.hasOwnProperty.call(message, "sql_state")) - writer.uint32(/* id 15, wireType 0 =*/120).int32(message.sql_state); if (message.last_sql_error != null && Object.hasOwnProperty.call(message, "last_sql_error")) - writer.uint32(/* id 16, wireType 2 =*/130).string(message.last_sql_error); + writer.uint32(/* id 15, wireType 2 =*/122).string(message.last_sql_error); return writer; }; @@ -63503,6 +63514,12 @@ $root.replicationdata = (function() { case 1: message.position = reader.string(); break; + case 2: + message.io_thread_running = reader.bool(); + break; + case 3: + message.sql_thread_running = reader.bool(); + break; case 4: message.replication_lag_seconds = reader.uint32(); break; @@ -63531,15 +63548,12 @@ $root.replicationdata = (function() { message.source_uuid = reader.string(); break; case 13: - message.io_state = reader.int32(); + message.io_thread_connecting = reader.bool(); break; case 14: message.last_io_error = reader.string(); break; case 15: - message.sql_state = reader.int32(); - break; - case 16: message.last_sql_error = reader.string(); break; default: @@ -63580,6 +63594,12 @@ $root.replicationdata = (function() { if (message.position != null && message.hasOwnProperty("position")) if (!$util.isString(message.position)) return "position: string expected"; + if (message.io_thread_running != null && message.hasOwnProperty("io_thread_running")) + if (typeof message.io_thread_running !== "boolean") + return "io_thread_running: boolean expected"; + if (message.sql_thread_running != null && message.hasOwnProperty("sql_thread_running")) + if (typeof message.sql_thread_running !== "boolean") + return "sql_thread_running: boolean expected"; if (message.replication_lag_seconds != null && message.hasOwnProperty("replication_lag_seconds")) if (!$util.isInteger(message.replication_lag_seconds)) return "replication_lag_seconds: integer expected"; @@ -63607,15 +63627,12 @@ $root.replicationdata = (function() { if (message.source_uuid != null && message.hasOwnProperty("source_uuid")) if (!$util.isString(message.source_uuid)) return "source_uuid: string expected"; - if (message.io_state != null && message.hasOwnProperty("io_state")) - if (!$util.isInteger(message.io_state)) - return "io_state: integer expected"; + if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) + if (typeof message.io_thread_connecting !== "boolean") + return "io_thread_connecting: boolean expected"; if (message.last_io_error != null && message.hasOwnProperty("last_io_error")) if (!$util.isString(message.last_io_error)) return "last_io_error: string expected"; - if (message.sql_state != null && message.hasOwnProperty("sql_state")) - if (!$util.isInteger(message.sql_state)) - return "sql_state: integer expected"; if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) if (!$util.isString(message.last_sql_error)) return "last_sql_error: string expected"; @@ -63636,6 +63653,10 @@ $root.replicationdata = (function() { var message = new $root.replicationdata.Status(); if (object.position != null) message.position = String(object.position); + if (object.io_thread_running != null) + message.io_thread_running = Boolean(object.io_thread_running); + if (object.sql_thread_running != null) + message.sql_thread_running = Boolean(object.sql_thread_running); if (object.replication_lag_seconds != null) message.replication_lag_seconds = object.replication_lag_seconds >>> 0; if (object.source_host != null) @@ -63654,12 +63675,10 @@ $root.replicationdata = (function() { message.source_server_id = object.source_server_id >>> 0; if (object.source_uuid != null) message.source_uuid = String(object.source_uuid); - if (object.io_state != null) - message.io_state = object.io_state | 0; + if (object.io_thread_connecting != null) + message.io_thread_connecting = Boolean(object.io_thread_connecting); if (object.last_io_error != null) message.last_io_error = String(object.last_io_error); - if (object.sql_state != null) - message.sql_state = object.sql_state | 0; if (object.last_sql_error != null) message.last_sql_error = String(object.last_sql_error); return message; @@ -63680,6 +63699,8 @@ $root.replicationdata = (function() { var object = {}; if (options.defaults) { object.position = ""; + object.io_thread_running = false; + object.sql_thread_running = false; object.replication_lag_seconds = 0; object.source_host = ""; object.source_port = 0; @@ -63689,13 +63710,16 @@ $root.replicationdata = (function() { object.file_relay_log_position = ""; object.source_server_id = 0; object.source_uuid = ""; - object.io_state = 0; + object.io_thread_connecting = false; object.last_io_error = ""; - object.sql_state = 0; object.last_sql_error = ""; } if (message.position != null && message.hasOwnProperty("position")) object.position = message.position; + if (message.io_thread_running != null && message.hasOwnProperty("io_thread_running")) + object.io_thread_running = message.io_thread_running; + if (message.sql_thread_running != null && message.hasOwnProperty("sql_thread_running")) + object.sql_thread_running = message.sql_thread_running; if (message.replication_lag_seconds != null && message.hasOwnProperty("replication_lag_seconds")) object.replication_lag_seconds = message.replication_lag_seconds; if (message.source_host != null && message.hasOwnProperty("source_host")) @@ -63714,12 +63738,10 @@ $root.replicationdata = (function() { object.source_server_id = message.source_server_id; if (message.source_uuid != null && message.hasOwnProperty("source_uuid")) object.source_uuid = message.source_uuid; - if (message.io_state != null && message.hasOwnProperty("io_state")) - object.io_state = message.io_state; + if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) + object.io_thread_connecting = message.io_thread_connecting; if (message.last_io_error != null && message.hasOwnProperty("last_io_error")) object.last_io_error = message.last_io_error; - if (message.sql_state != null && message.hasOwnProperty("sql_state")) - object.sql_state = message.sql_state; if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) object.last_sql_error = message.last_sql_error; return object; From fd66496b56abd453bee3d15ccc0cb3652861baa3 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 13:58:17 -0400 Subject: [PATCH 02/14] This adds the new state fields back so that we can switch to them in v15 Signed-off-by: Matt Lord --- .../replicationdata/replicationdata.pb.go | 81 ++++++---- .../replicationdata_vtproto.pb.go | 66 ++++++++- proto/replicationdata.proto | 9 +- web/vtadmin/src/proto/vtadmin.d.ts | 36 +++++ web/vtadmin/src/proto/vtadmin.js | 138 +++++++++++++++++- 5 files changed, 292 insertions(+), 38 deletions(-) diff --git a/go/vt/proto/replicationdata/replicationdata.pb.go b/go/vt/proto/replicationdata/replicationdata.pb.go index 97d782b90c5..a2c134dcaaa 100644 --- a/go/vt/proto/replicationdata/replicationdata.pb.go +++ b/go/vt/proto/replicationdata/replicationdata.pb.go @@ -91,7 +91,10 @@ type Status struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + // These fields need to be removed in Vitess 15 and fully replaced by the io_state and sql_state fields + // reserved 2, 3, 13; + // reserved "io_thread_running", "sql_thread_running", "io_thread_connecting"; IoThreadRunning bool `protobuf:"varint,2,opt,name=io_thread_running,json=ioThreadRunning,proto3" json:"io_thread_running,omitempty"` SqlThreadRunning bool `protobuf:"varint,3,opt,name=sql_thread_running,json=sqlThreadRunning,proto3" json:"sql_thread_running,omitempty"` ReplicationLagSeconds uint32 `protobuf:"varint,4,opt,name=replication_lag_seconds,json=replicationLagSeconds,proto3" json:"replication_lag_seconds,omitempty"` @@ -105,8 +108,10 @@ type Status struct { SourceServerId uint32 `protobuf:"varint,11,opt,name=source_server_id,json=sourceServerId,proto3" json:"source_server_id,omitempty"` SourceUuid string `protobuf:"bytes,12,opt,name=source_uuid,json=sourceUuid,proto3" json:"source_uuid,omitempty"` IoThreadConnecting bool `protobuf:"varint,13,opt,name=io_thread_connecting,json=ioThreadConnecting,proto3" json:"io_thread_connecting,omitempty"` - LastIoError string `protobuf:"bytes,14,opt,name=last_io_error,json=lastIoError,proto3" json:"last_io_error,omitempty"` - LastSqlError string `protobuf:"bytes,15,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` + IoState int32 `protobuf:"varint,14,opt,name=io_state,json=ioState,proto3" json:"io_state,omitempty"` + LastIoError string `protobuf:"bytes,15,opt,name=last_io_error,json=lastIoError,proto3" json:"last_io_error,omitempty"` + SqlState int32 `protobuf:"varint,16,opt,name=sql_state,json=sqlState,proto3" json:"sql_state,omitempty"` + LastSqlError string `protobuf:"bytes,17,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` } func (x *Status) Reset() { @@ -232,6 +237,13 @@ func (x *Status) GetIoThreadConnecting() bool { return false } +func (x *Status) GetIoState() int32 { + if x != nil { + return x.IoState + } + return 0 +} + func (x *Status) GetLastIoError() string { if x != nil { return x.LastIoError @@ -239,6 +251,13 @@ func (x *Status) GetLastIoError() string { return "" } +func (x *Status) GetSqlState() int32 { + if x != nil { + return x.SqlState + } + return 0 +} + func (x *Status) GetLastSqlError() string { if x != nil { return x.LastSqlError @@ -364,7 +383,7 @@ var File_replicationdata_proto protoreflect.FileDescriptor var file_replicationdata_proto_rawDesc = []byte{ 0x0a, 0x15, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x22, 0xee, 0x04, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa6, 0x05, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6e, @@ -399,31 +418,35 @@ var file_replicationdata_proto_rawDesc = []byte{ 0x14, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x69, 0x6f, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x12, - 0x22, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6f, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6f, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, - 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, - 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x62, 0x65, 0x66, - 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x61, 0x66, 0x74, - 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3b, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x49, - 0x4f, 0x41, 0x4e, 0x44, 0x53, 0x51, 0x4c, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x10, 0x00, 0x12, - 0x10, 0x0a, 0x0c, 0x49, 0x4f, 0x54, 0x48, 0x52, 0x45, 0x41, 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, - 0x01, 0x42, 0x2e, 0x5a, 0x2c, 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, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x19, 0x0a, 0x08, 0x69, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x69, 0x6f, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x61, + 0x73, 0x74, 0x5f, 0x69, 0x6f, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1b, + 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x73, 0x71, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6c, + 0x61, 0x73, 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x11, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, + 0x66, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x61, + 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x50, 0x72, + 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x66, 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3b, 0x0a, 0x13, + 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, + 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x4f, 0x41, 0x4e, 0x44, 0x53, 0x51, 0x4c, 0x54, + 0x48, 0x52, 0x45, 0x41, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x4f, 0x54, 0x48, 0x52, + 0x45, 0x41, 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x01, 0x42, 0x2e, 0x5a, 0x2c, 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, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go index 3bced0530ef..ac1dedf5458 100644 --- a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go +++ b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go @@ -53,14 +53,28 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { copy(dAtA[i:], m.LastSqlError) i = encodeVarint(dAtA, i, uint64(len(m.LastSqlError))) i-- - dAtA[i] = 0x7a + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + if m.SqlState != 0 { + i = encodeVarint(dAtA, i, uint64(m.SqlState)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 } if len(m.LastIoError) > 0 { i -= len(m.LastIoError) copy(dAtA[i:], m.LastIoError) i = encodeVarint(dAtA, i, uint64(len(m.LastIoError))) i-- - dAtA[i] = 0x72 + dAtA[i] = 0x7a + } + if m.IoState != 0 { + i = encodeVarint(dAtA, i, uint64(m.IoState)) + i-- + dAtA[i] = 0x70 } if m.IoThreadConnecting { i-- @@ -319,13 +333,19 @@ func (m *Status) SizeVT() (n int) { if m.IoThreadConnecting { n += 2 } + if m.IoState != 0 { + n += 1 + sov(uint64(m.IoState)) + } l = len(m.LastIoError) if l > 0 { n += 1 + l + sov(uint64(l)) } + if m.SqlState != 0 { + n += 2 + sov(uint64(m.SqlState)) + } l = len(m.LastSqlError) if l > 0 { - n += 1 + l + sov(uint64(l)) + n += 2 + l + sov(uint64(l)) } if m.unknownFields != nil { n += len(m.unknownFields) @@ -737,6 +757,25 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } m.IoThreadConnecting = bool(v != 0) case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IoState", wireType) + } + m.IoState = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.IoState |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastIoError", wireType) } @@ -768,7 +807,26 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } m.LastIoError = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 15: + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SqlState", wireType) + } + m.SqlState = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SqlState |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 17: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastSqlError", wireType) } diff --git a/proto/replicationdata.proto b/proto/replicationdata.proto index 87a6ea331e7..d378c08dc1f 100644 --- a/proto/replicationdata.proto +++ b/proto/replicationdata.proto @@ -25,6 +25,9 @@ package replicationdata; // flavor-specific command and parsed into a Position and fields. message Status { string position = 1; + // These fields should be removed in Vitess 15+ and fully replaced by the io_state and sql_state fields + // reserved 2, 3, 13; + // reserved "io_thread_running", "sql_thread_running", "io_thread_connecting"; bool io_thread_running = 2; bool sql_thread_running = 3; uint32 replication_lag_seconds = 4; @@ -38,8 +41,10 @@ message Status { uint32 source_server_id = 11; string source_uuid = 12; bool io_thread_connecting = 13; - string last_io_error = 14; - string last_sql_error = 15; + int32 io_state = 14; + string last_io_error = 15; + int32 sql_state = 16; + string last_sql_error = 17; } // StopReplicationStatus represents the replication status before calling StopReplication, and the replication status collected immediately after diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index cafafa89ef7..e04334e7fc9 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -26896,9 +26896,15 @@ export namespace replicationdata { /** Status io_thread_connecting */ io_thread_connecting?: (boolean|null); + /** Status io_state */ + io_state?: (number|null); + /** Status last_io_error */ last_io_error?: (string|null); + /** Status sql_state */ + sql_state?: (number|null); + /** Status last_sql_error */ last_sql_error?: (string|null); } @@ -26951,9 +26957,15 @@ export namespace replicationdata { /** Status io_thread_connecting. */ public io_thread_connecting: boolean; + /** Status io_state. */ + public io_state: number; + /** Status last_io_error. */ public last_io_error: string; + /** Status sql_state. */ + public sql_state: number; + /** Status last_sql_error. */ public last_sql_error: string; @@ -28590,6 +28602,12 @@ export namespace vtctldata { /** MaterializeSettings materialization_intent */ materialization_intent?: (vtctldata.MaterializationIntent|null); + + /** MaterializeSettings source_time_zone */ + source_time_zone?: (string|null); + + /** MaterializeSettings target_time_zone */ + target_time_zone?: (string|null); } /** Represents a MaterializeSettings. */ @@ -28628,6 +28646,12 @@ export namespace vtctldata { /** MaterializeSettings materialization_intent. */ public materialization_intent: vtctldata.MaterializationIntent; + /** MaterializeSettings source_time_zone. */ + public source_time_zone: string; + + /** MaterializeSettings target_time_zone. */ + public target_time_zone: string; + /** * Creates a new MaterializeSettings instance using the specified properties. * @param [properties] Properties to set @@ -45819,6 +45843,12 @@ export namespace binlogdata { /** BinlogSource external_cluster */ external_cluster?: (string|null); + + /** BinlogSource source_time_zone */ + source_time_zone?: (string|null); + + /** BinlogSource target_time_zone */ + target_time_zone?: (string|null); } /** Represents a BinlogSource. */ @@ -45860,6 +45890,12 @@ export namespace binlogdata { /** BinlogSource external_cluster. */ public external_cluster: string; + /** BinlogSource source_time_zone. */ + public source_time_zone: string; + + /** BinlogSource target_time_zone. */ + public target_time_zone: string; + /** * Creates a new BinlogSource 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 61d1b71f9cd..cf013ea65c6 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -63284,7 +63284,9 @@ $root.replicationdata = (function() { * @property {number|null} [source_server_id] Status source_server_id * @property {string|null} [source_uuid] Status source_uuid * @property {boolean|null} [io_thread_connecting] Status io_thread_connecting + * @property {number|null} [io_state] Status io_state * @property {string|null} [last_io_error] Status last_io_error + * @property {number|null} [sql_state] Status sql_state * @property {string|null} [last_sql_error] Status last_sql_error */ @@ -63407,6 +63409,14 @@ $root.replicationdata = (function() { */ Status.prototype.io_thread_connecting = false; + /** + * Status io_state. + * @member {number} io_state + * @memberof replicationdata.Status + * @instance + */ + Status.prototype.io_state = 0; + /** * Status last_io_error. * @member {string} last_io_error @@ -63415,6 +63425,14 @@ $root.replicationdata = (function() { */ Status.prototype.last_io_error = ""; + /** + * Status sql_state. + * @member {number} sql_state + * @memberof replicationdata.Status + * @instance + */ + Status.prototype.sql_state = 0; + /** * Status last_sql_error. * @member {string} last_sql_error @@ -63473,10 +63491,14 @@ $root.replicationdata = (function() { writer.uint32(/* id 12, wireType 2 =*/98).string(message.source_uuid); if (message.io_thread_connecting != null && Object.hasOwnProperty.call(message, "io_thread_connecting")) writer.uint32(/* id 13, wireType 0 =*/104).bool(message.io_thread_connecting); + if (message.io_state != null && Object.hasOwnProperty.call(message, "io_state")) + writer.uint32(/* id 14, wireType 0 =*/112).int32(message.io_state); if (message.last_io_error != null && Object.hasOwnProperty.call(message, "last_io_error")) - writer.uint32(/* id 14, wireType 2 =*/114).string(message.last_io_error); + writer.uint32(/* id 15, wireType 2 =*/122).string(message.last_io_error); + if (message.sql_state != null && Object.hasOwnProperty.call(message, "sql_state")) + writer.uint32(/* id 16, wireType 0 =*/128).int32(message.sql_state); if (message.last_sql_error != null && Object.hasOwnProperty.call(message, "last_sql_error")) - writer.uint32(/* id 15, wireType 2 =*/122).string(message.last_sql_error); + writer.uint32(/* id 17, wireType 2 =*/138).string(message.last_sql_error); return writer; }; @@ -63551,9 +63573,15 @@ $root.replicationdata = (function() { message.io_thread_connecting = reader.bool(); break; case 14: - message.last_io_error = reader.string(); + message.io_state = reader.int32(); break; case 15: + message.last_io_error = reader.string(); + break; + case 16: + message.sql_state = reader.int32(); + break; + case 17: message.last_sql_error = reader.string(); break; default: @@ -63630,9 +63658,15 @@ $root.replicationdata = (function() { if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) if (typeof message.io_thread_connecting !== "boolean") return "io_thread_connecting: boolean expected"; + if (message.io_state != null && message.hasOwnProperty("io_state")) + if (!$util.isInteger(message.io_state)) + return "io_state: integer expected"; if (message.last_io_error != null && message.hasOwnProperty("last_io_error")) if (!$util.isString(message.last_io_error)) return "last_io_error: string expected"; + if (message.sql_state != null && message.hasOwnProperty("sql_state")) + if (!$util.isInteger(message.sql_state)) + return "sql_state: integer expected"; if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) if (!$util.isString(message.last_sql_error)) return "last_sql_error: string expected"; @@ -63677,8 +63711,12 @@ $root.replicationdata = (function() { message.source_uuid = String(object.source_uuid); if (object.io_thread_connecting != null) message.io_thread_connecting = Boolean(object.io_thread_connecting); + if (object.io_state != null) + message.io_state = object.io_state | 0; if (object.last_io_error != null) message.last_io_error = String(object.last_io_error); + if (object.sql_state != null) + message.sql_state = object.sql_state | 0; if (object.last_sql_error != null) message.last_sql_error = String(object.last_sql_error); return message; @@ -63711,7 +63749,9 @@ $root.replicationdata = (function() { object.source_server_id = 0; object.source_uuid = ""; object.io_thread_connecting = false; + object.io_state = 0; object.last_io_error = ""; + object.sql_state = 0; object.last_sql_error = ""; } if (message.position != null && message.hasOwnProperty("position")) @@ -63740,8 +63780,12 @@ $root.replicationdata = (function() { object.source_uuid = message.source_uuid; if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) object.io_thread_connecting = message.io_thread_connecting; + if (message.io_state != null && message.hasOwnProperty("io_state")) + object.io_state = message.io_state; if (message.last_io_error != null && message.hasOwnProperty("last_io_error")) object.last_io_error = message.last_io_error; + if (message.sql_state != null && message.hasOwnProperty("sql_state")) + object.sql_state = message.sql_state; if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) object.last_sql_error = message.last_sql_error; return object; @@ -67759,6 +67803,8 @@ $root.vtctldata = (function() { * @property {string|null} [tablet_types] MaterializeSettings tablet_types * @property {string|null} [external_cluster] MaterializeSettings external_cluster * @property {vtctldata.MaterializationIntent|null} [materialization_intent] MaterializeSettings materialization_intent + * @property {string|null} [source_time_zone] MaterializeSettings source_time_zone + * @property {string|null} [target_time_zone] MaterializeSettings target_time_zone */ /** @@ -67849,6 +67895,22 @@ $root.vtctldata = (function() { */ MaterializeSettings.prototype.materialization_intent = 0; + /** + * MaterializeSettings source_time_zone. + * @member {string} source_time_zone + * @memberof vtctldata.MaterializeSettings + * @instance + */ + MaterializeSettings.prototype.source_time_zone = ""; + + /** + * MaterializeSettings target_time_zone. + * @member {string} target_time_zone + * @memberof vtctldata.MaterializeSettings + * @instance + */ + MaterializeSettings.prototype.target_time_zone = ""; + /** * Creates a new MaterializeSettings instance using the specified properties. * @function create @@ -67892,6 +67954,10 @@ $root.vtctldata = (function() { writer.uint32(/* id 8, wireType 2 =*/66).string(message.external_cluster); if (message.materialization_intent != null && Object.hasOwnProperty.call(message, "materialization_intent")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.materialization_intent); + if (message.source_time_zone != null && Object.hasOwnProperty.call(message, "source_time_zone")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.source_time_zone); + if (message.target_time_zone != null && Object.hasOwnProperty.call(message, "target_time_zone")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.target_time_zone); return writer; }; @@ -67955,6 +68021,12 @@ $root.vtctldata = (function() { case 9: message.materialization_intent = reader.int32(); break; + case 10: + message.source_time_zone = reader.string(); + break; + case 11: + message.target_time_zone = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -68029,6 +68101,12 @@ $root.vtctldata = (function() { case 2: break; } + if (message.source_time_zone != null && message.hasOwnProperty("source_time_zone")) + if (!$util.isString(message.source_time_zone)) + return "source_time_zone: string expected"; + if (message.target_time_zone != null && message.hasOwnProperty("target_time_zone")) + if (!$util.isString(message.target_time_zone)) + return "target_time_zone: string expected"; return null; }; @@ -68082,6 +68160,10 @@ $root.vtctldata = (function() { message.materialization_intent = 2; break; } + if (object.source_time_zone != null) + message.source_time_zone = String(object.source_time_zone); + if (object.target_time_zone != null) + message.target_time_zone = String(object.target_time_zone); return message; }; @@ -68109,6 +68191,8 @@ $root.vtctldata = (function() { object.tablet_types = ""; object.external_cluster = ""; object.materialization_intent = options.enums === String ? "CUSTOM" : 0; + object.source_time_zone = ""; + object.target_time_zone = ""; } if (message.workflow != null && message.hasOwnProperty("workflow")) object.workflow = message.workflow; @@ -68131,6 +68215,10 @@ $root.vtctldata = (function() { object.external_cluster = message.external_cluster; if (message.materialization_intent != null && message.hasOwnProperty("materialization_intent")) object.materialization_intent = options.enums === String ? $root.vtctldata.MaterializationIntent[message.materialization_intent] : message.materialization_intent; + if (message.source_time_zone != null && message.hasOwnProperty("source_time_zone")) + object.source_time_zone = message.source_time_zone; + if (message.target_time_zone != null && message.hasOwnProperty("target_time_zone")) + object.target_time_zone = message.target_time_zone; return object; }; @@ -108038,6 +108126,8 @@ $root.binlogdata = (function() { * @property {string|null} [external_mysql] BinlogSource external_mysql * @property {boolean|null} [stop_after_copy] BinlogSource stop_after_copy * @property {string|null} [external_cluster] BinlogSource external_cluster + * @property {string|null} [source_time_zone] BinlogSource source_time_zone + * @property {string|null} [target_time_zone] BinlogSource target_time_zone */ /** @@ -108136,6 +108226,22 @@ $root.binlogdata = (function() { */ BinlogSource.prototype.external_cluster = ""; + /** + * BinlogSource source_time_zone. + * @member {string} source_time_zone + * @memberof binlogdata.BinlogSource + * @instance + */ + BinlogSource.prototype.source_time_zone = ""; + + /** + * BinlogSource target_time_zone. + * @member {string} target_time_zone + * @memberof binlogdata.BinlogSource + * @instance + */ + BinlogSource.prototype.target_time_zone = ""; + /** * Creates a new BinlogSource instance using the specified properties. * @function create @@ -108181,6 +108287,10 @@ $root.binlogdata = (function() { writer.uint32(/* id 9, wireType 0 =*/72).bool(message.stop_after_copy); if (message.external_cluster != null && Object.hasOwnProperty.call(message, "external_cluster")) writer.uint32(/* id 10, wireType 2 =*/82).string(message.external_cluster); + if (message.source_time_zone != null && Object.hasOwnProperty.call(message, "source_time_zone")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.source_time_zone); + if (message.target_time_zone != null && Object.hasOwnProperty.call(message, "target_time_zone")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.target_time_zone); return writer; }; @@ -108247,6 +108357,12 @@ $root.binlogdata = (function() { case 10: message.external_cluster = reader.string(); break; + case 11: + message.source_time_zone = reader.string(); + break; + case 12: + message.target_time_zone = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -108341,6 +108457,12 @@ $root.binlogdata = (function() { if (message.external_cluster != null && message.hasOwnProperty("external_cluster")) if (!$util.isString(message.external_cluster)) return "external_cluster: string expected"; + if (message.source_time_zone != null && message.hasOwnProperty("source_time_zone")) + if (!$util.isString(message.source_time_zone)) + return "source_time_zone: string expected"; + if (message.target_time_zone != null && message.hasOwnProperty("target_time_zone")) + if (!$util.isString(message.target_time_zone)) + return "target_time_zone: string expected"; return null; }; @@ -108447,6 +108569,10 @@ $root.binlogdata = (function() { message.stop_after_copy = Boolean(object.stop_after_copy); if (object.external_cluster != null) message.external_cluster = String(object.external_cluster); + if (object.source_time_zone != null) + message.source_time_zone = String(object.source_time_zone); + if (object.target_time_zone != null) + message.target_time_zone = String(object.target_time_zone); return message; }; @@ -108475,6 +108601,8 @@ $root.binlogdata = (function() { object.external_mysql = ""; object.stop_after_copy = false; object.external_cluster = ""; + object.source_time_zone = ""; + object.target_time_zone = ""; } if (message.keyspace != null && message.hasOwnProperty("keyspace")) object.keyspace = message.keyspace; @@ -108499,6 +108627,10 @@ $root.binlogdata = (function() { object.stop_after_copy = message.stop_after_copy; if (message.external_cluster != null && message.hasOwnProperty("external_cluster")) object.external_cluster = message.external_cluster; + if (message.source_time_zone != null && message.hasOwnProperty("source_time_zone")) + object.source_time_zone = message.source_time_zone; + if (message.target_time_zone != null && message.hasOwnProperty("target_time_zone")) + object.target_time_zone = message.target_time_zone; return object; }; From 0d18e9d266b108a524fb5d1cd2b7cd57827efa99 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 14:11:26 -0400 Subject: [PATCH 03/14] Allow for safe/smooth upgrades within 14.0-SNAPSHOT We are only appending the last io_thread_connecting field Signed-off-by: Matt Lord --- .../replicationdata/replicationdata.pb.go | 54 ++++++------ .../replicationdata_vtproto.pb.go | 84 +++++++++---------- proto/replicationdata.proto | 12 +-- web/vtadmin/src/proto/vtadmin.d.ts | 12 +-- web/vtadmin/src/proto/vtadmin.js | 56 ++++++------- 5 files changed, 109 insertions(+), 109 deletions(-) diff --git a/go/vt/proto/replicationdata/replicationdata.pb.go b/go/vt/proto/replicationdata/replicationdata.pb.go index a2c134dcaaa..8053a800127 100644 --- a/go/vt/proto/replicationdata/replicationdata.pb.go +++ b/go/vt/proto/replicationdata/replicationdata.pb.go @@ -92,8 +92,8 @@ type Status struct { unknownFields protoimpl.UnknownFields Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - // These fields need to be removed in Vitess 15 and fully replaced by the io_state and sql_state fields - // reserved 2, 3, 13; + // These fields should be removed in Vitess 15+ and fully replaced by the io_state and sql_state fields + // reserved 2, 3, 17; // reserved "io_thread_running", "sql_thread_running", "io_thread_connecting"; IoThreadRunning bool `protobuf:"varint,2,opt,name=io_thread_running,json=ioThreadRunning,proto3" json:"io_thread_running,omitempty"` SqlThreadRunning bool `protobuf:"varint,3,opt,name=sql_thread_running,json=sqlThreadRunning,proto3" json:"sql_thread_running,omitempty"` @@ -107,11 +107,11 @@ type Status struct { FileRelayLogPosition string `protobuf:"bytes,10,opt,name=file_relay_log_position,json=fileRelayLogPosition,proto3" json:"file_relay_log_position,omitempty"` SourceServerId uint32 `protobuf:"varint,11,opt,name=source_server_id,json=sourceServerId,proto3" json:"source_server_id,omitempty"` SourceUuid string `protobuf:"bytes,12,opt,name=source_uuid,json=sourceUuid,proto3" json:"source_uuid,omitempty"` - IoThreadConnecting bool `protobuf:"varint,13,opt,name=io_thread_connecting,json=ioThreadConnecting,proto3" json:"io_thread_connecting,omitempty"` - IoState int32 `protobuf:"varint,14,opt,name=io_state,json=ioState,proto3" json:"io_state,omitempty"` - LastIoError string `protobuf:"bytes,15,opt,name=last_io_error,json=lastIoError,proto3" json:"last_io_error,omitempty"` - SqlState int32 `protobuf:"varint,16,opt,name=sql_state,json=sqlState,proto3" json:"sql_state,omitempty"` - LastSqlError string `protobuf:"bytes,17,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` + IoState int32 `protobuf:"varint,13,opt,name=io_state,json=ioState,proto3" json:"io_state,omitempty"` + LastIoError string `protobuf:"bytes,14,opt,name=last_io_error,json=lastIoError,proto3" json:"last_io_error,omitempty"` + SqlState int32 `protobuf:"varint,15,opt,name=sql_state,json=sqlState,proto3" json:"sql_state,omitempty"` + LastSqlError string `protobuf:"bytes,16,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` + IoThreadConnecting bool `protobuf:"varint,17,opt,name=io_thread_connecting,json=ioThreadConnecting,proto3" json:"io_thread_connecting,omitempty"` } func (x *Status) Reset() { @@ -230,13 +230,6 @@ func (x *Status) GetSourceUuid() string { return "" } -func (x *Status) GetIoThreadConnecting() bool { - if x != nil { - return x.IoThreadConnecting - } - return false -} - func (x *Status) GetIoState() int32 { if x != nil { return x.IoState @@ -265,6 +258,13 @@ func (x *Status) GetLastSqlError() string { return "" } +func (x *Status) GetIoThreadConnecting() bool { + if x != nil { + return x.IoThreadConnecting + } + return false +} + // StopReplicationStatus represents the replication status before calling StopReplication, and the replication status collected immediately after // calling StopReplication. type StopReplicationStatus struct { @@ -414,19 +414,19 @@ var file_replicationdata_proto_rawDesc = []byte{ 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x75, 0x69, 0x64, 0x12, 0x30, 0x0a, - 0x14, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, - 0x63, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x69, 0x6f, 0x54, - 0x68, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x12, - 0x19, 0x0a, 0x08, 0x69, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x69, 0x6f, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x61, - 0x73, 0x74, 0x5f, 0x69, 0x6f, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1b, - 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x73, 0x71, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6c, - 0x61, 0x73, 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x11, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x75, 0x69, 0x64, 0x12, 0x19, 0x0a, + 0x08, 0x69, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x07, 0x69, 0x6f, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, + 0x5f, 0x69, 0x6f, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, + 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x73, 0x71, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, + 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, + 0x30, 0x0a, 0x14, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x63, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x69, + 0x6f, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, + 0x67, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, diff --git a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go index ac1dedf5458..f42a15091bc 100644 --- a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go +++ b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go @@ -48,6 +48,18 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.IoThreadConnecting { + i-- + if m.IoThreadConnecting { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } if len(m.LastSqlError) > 0 { i -= len(m.LastSqlError) copy(dAtA[i:], m.LastSqlError) @@ -55,35 +67,23 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0x8a + dAtA[i] = 0x82 } if m.SqlState != 0 { i = encodeVarint(dAtA, i, uint64(m.SqlState)) i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x80 + dAtA[i] = 0x78 } if len(m.LastIoError) > 0 { i -= len(m.LastIoError) copy(dAtA[i:], m.LastIoError) i = encodeVarint(dAtA, i, uint64(len(m.LastIoError))) i-- - dAtA[i] = 0x7a + dAtA[i] = 0x72 } if m.IoState != 0 { i = encodeVarint(dAtA, i, uint64(m.IoState)) i-- - dAtA[i] = 0x70 - } - if m.IoThreadConnecting { - i-- - if m.IoThreadConnecting { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- dAtA[i] = 0x68 } if len(m.SourceUuid) > 0 { @@ -330,9 +330,6 @@ func (m *Status) SizeVT() (n int) { if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.IoThreadConnecting { - n += 2 - } if m.IoState != 0 { n += 1 + sov(uint64(m.IoState)) } @@ -341,12 +338,15 @@ func (m *Status) SizeVT() (n int) { n += 1 + l + sov(uint64(l)) } if m.SqlState != 0 { - n += 2 + sov(uint64(m.SqlState)) + n += 1 + sov(uint64(m.SqlState)) } l = len(m.LastSqlError) if l > 0 { n += 2 + l + sov(uint64(l)) } + if m.IoThreadConnecting { + n += 3 + } if m.unknownFields != nil { n += len(m.unknownFields) } @@ -737,26 +737,6 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { m.SourceUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 13: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IoThreadConnecting", 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.IoThreadConnecting = bool(v != 0) - case 14: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field IoState", wireType) } @@ -775,7 +755,7 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { break } } - case 15: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastIoError", wireType) } @@ -807,7 +787,7 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } m.LastIoError = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 16: + case 15: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SqlState", wireType) } @@ -826,7 +806,7 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { break } } - case 17: + case 16: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastSqlError", wireType) } @@ -858,6 +838,26 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } m.LastSqlError = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IoThreadConnecting", 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.IoThreadConnecting = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/proto/replicationdata.proto b/proto/replicationdata.proto index d378c08dc1f..f6bb8df1a06 100644 --- a/proto/replicationdata.proto +++ b/proto/replicationdata.proto @@ -26,7 +26,7 @@ package replicationdata; message Status { string position = 1; // These fields should be removed in Vitess 15+ and fully replaced by the io_state and sql_state fields - // reserved 2, 3, 13; + // reserved 2, 3, 17; // reserved "io_thread_running", "sql_thread_running", "io_thread_connecting"; bool io_thread_running = 2; bool sql_thread_running = 3; @@ -40,11 +40,11 @@ message Status { string file_relay_log_position = 10; uint32 source_server_id = 11; string source_uuid = 12; - bool io_thread_connecting = 13; - int32 io_state = 14; - string last_io_error = 15; - int32 sql_state = 16; - string last_sql_error = 17; + int32 io_state = 13; + string last_io_error = 14; + int32 sql_state = 15; + string last_sql_error = 16; + bool io_thread_connecting = 17; } // StopReplicationStatus represents the replication status before calling StopReplication, and the replication status collected immediately after diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index e04334e7fc9..57fcb758727 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -26893,9 +26893,6 @@ export namespace replicationdata { /** Status source_uuid */ source_uuid?: (string|null); - /** Status io_thread_connecting */ - io_thread_connecting?: (boolean|null); - /** Status io_state */ io_state?: (number|null); @@ -26907,6 +26904,9 @@ export namespace replicationdata { /** Status last_sql_error */ last_sql_error?: (string|null); + + /** Status io_thread_connecting */ + io_thread_connecting?: (boolean|null); } /** Represents a Status. */ @@ -26954,9 +26954,6 @@ export namespace replicationdata { /** Status source_uuid. */ public source_uuid: string; - /** Status io_thread_connecting. */ - public io_thread_connecting: boolean; - /** Status io_state. */ public io_state: number; @@ -26969,6 +26966,9 @@ export namespace replicationdata { /** Status last_sql_error. */ public last_sql_error: string; + /** Status io_thread_connecting. */ + public io_thread_connecting: boolean; + /** * Creates a new Status 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 cf013ea65c6..5df8e60eb33 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -63283,11 +63283,11 @@ $root.replicationdata = (function() { * @property {string|null} [file_relay_log_position] Status file_relay_log_position * @property {number|null} [source_server_id] Status source_server_id * @property {string|null} [source_uuid] Status source_uuid - * @property {boolean|null} [io_thread_connecting] Status io_thread_connecting * @property {number|null} [io_state] Status io_state * @property {string|null} [last_io_error] Status last_io_error * @property {number|null} [sql_state] Status sql_state * @property {string|null} [last_sql_error] Status last_sql_error + * @property {boolean|null} [io_thread_connecting] Status io_thread_connecting */ /** @@ -63401,14 +63401,6 @@ $root.replicationdata = (function() { */ Status.prototype.source_uuid = ""; - /** - * Status io_thread_connecting. - * @member {boolean} io_thread_connecting - * @memberof replicationdata.Status - * @instance - */ - Status.prototype.io_thread_connecting = false; - /** * Status io_state. * @member {number} io_state @@ -63441,6 +63433,14 @@ $root.replicationdata = (function() { */ Status.prototype.last_sql_error = ""; + /** + * Status io_thread_connecting. + * @member {boolean} io_thread_connecting + * @memberof replicationdata.Status + * @instance + */ + Status.prototype.io_thread_connecting = false; + /** * Creates a new Status instance using the specified properties. * @function create @@ -63489,16 +63489,16 @@ $root.replicationdata = (function() { writer.uint32(/* id 11, wireType 0 =*/88).uint32(message.source_server_id); if (message.source_uuid != null && Object.hasOwnProperty.call(message, "source_uuid")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.source_uuid); - if (message.io_thread_connecting != null && Object.hasOwnProperty.call(message, "io_thread_connecting")) - writer.uint32(/* id 13, wireType 0 =*/104).bool(message.io_thread_connecting); if (message.io_state != null && Object.hasOwnProperty.call(message, "io_state")) - writer.uint32(/* id 14, wireType 0 =*/112).int32(message.io_state); + writer.uint32(/* id 13, wireType 0 =*/104).int32(message.io_state); if (message.last_io_error != null && Object.hasOwnProperty.call(message, "last_io_error")) - writer.uint32(/* id 15, wireType 2 =*/122).string(message.last_io_error); + writer.uint32(/* id 14, wireType 2 =*/114).string(message.last_io_error); if (message.sql_state != null && Object.hasOwnProperty.call(message, "sql_state")) - writer.uint32(/* id 16, wireType 0 =*/128).int32(message.sql_state); + writer.uint32(/* id 15, wireType 0 =*/120).int32(message.sql_state); if (message.last_sql_error != null && Object.hasOwnProperty.call(message, "last_sql_error")) - writer.uint32(/* id 17, wireType 2 =*/138).string(message.last_sql_error); + writer.uint32(/* id 16, wireType 2 =*/130).string(message.last_sql_error); + if (message.io_thread_connecting != null && Object.hasOwnProperty.call(message, "io_thread_connecting")) + writer.uint32(/* id 17, wireType 0 =*/136).bool(message.io_thread_connecting); return writer; }; @@ -63570,19 +63570,19 @@ $root.replicationdata = (function() { message.source_uuid = reader.string(); break; case 13: - message.io_thread_connecting = reader.bool(); + message.io_state = reader.int32(); break; case 14: - message.io_state = reader.int32(); + message.last_io_error = reader.string(); break; case 15: - message.last_io_error = reader.string(); + message.sql_state = reader.int32(); break; case 16: - message.sql_state = reader.int32(); + message.last_sql_error = reader.string(); break; case 17: - message.last_sql_error = reader.string(); + message.io_thread_connecting = reader.bool(); break; default: reader.skipType(tag & 7); @@ -63655,9 +63655,6 @@ $root.replicationdata = (function() { if (message.source_uuid != null && message.hasOwnProperty("source_uuid")) if (!$util.isString(message.source_uuid)) return "source_uuid: string expected"; - if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) - if (typeof message.io_thread_connecting !== "boolean") - return "io_thread_connecting: boolean expected"; if (message.io_state != null && message.hasOwnProperty("io_state")) if (!$util.isInteger(message.io_state)) return "io_state: integer expected"; @@ -63670,6 +63667,9 @@ $root.replicationdata = (function() { if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) if (!$util.isString(message.last_sql_error)) return "last_sql_error: string expected"; + if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) + if (typeof message.io_thread_connecting !== "boolean") + return "io_thread_connecting: boolean expected"; return null; }; @@ -63709,8 +63709,6 @@ $root.replicationdata = (function() { message.source_server_id = object.source_server_id >>> 0; if (object.source_uuid != null) message.source_uuid = String(object.source_uuid); - if (object.io_thread_connecting != null) - message.io_thread_connecting = Boolean(object.io_thread_connecting); if (object.io_state != null) message.io_state = object.io_state | 0; if (object.last_io_error != null) @@ -63719,6 +63717,8 @@ $root.replicationdata = (function() { message.sql_state = object.sql_state | 0; if (object.last_sql_error != null) message.last_sql_error = String(object.last_sql_error); + if (object.io_thread_connecting != null) + message.io_thread_connecting = Boolean(object.io_thread_connecting); return message; }; @@ -63748,11 +63748,11 @@ $root.replicationdata = (function() { object.file_relay_log_position = ""; object.source_server_id = 0; object.source_uuid = ""; - object.io_thread_connecting = false; object.io_state = 0; object.last_io_error = ""; object.sql_state = 0; object.last_sql_error = ""; + object.io_thread_connecting = false; } if (message.position != null && message.hasOwnProperty("position")) object.position = message.position; @@ -63778,8 +63778,6 @@ $root.replicationdata = (function() { object.source_server_id = message.source_server_id; if (message.source_uuid != null && message.hasOwnProperty("source_uuid")) object.source_uuid = message.source_uuid; - if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) - object.io_thread_connecting = message.io_thread_connecting; if (message.io_state != null && message.hasOwnProperty("io_state")) object.io_state = message.io_state; if (message.last_io_error != null && message.hasOwnProperty("last_io_error")) @@ -63788,6 +63786,8 @@ $root.replicationdata = (function() { object.sql_state = message.sql_state; if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) object.last_sql_error = message.last_sql_error; + if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) + object.io_thread_connecting = message.io_thread_connecting; return object; }; From 3dd78956f8522f4288abcb76eaea6ebd2255196f Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 14:45:36 -0400 Subject: [PATCH 04/14] Avoid intermediate io_thread_connecting protobuf field Signed-off-by: Matt Lord --- go/mysql/replication_status.go | 40 ++++++------- .../replicationdata/replicationdata.pb.go | 60 ++++++++----------- .../replicationdata_vtproto.pb.go | 35 ----------- proto/replicationdata.proto | 5 +- web/vtadmin/src/proto/vtadmin.d.ts | 6 -- web/vtadmin/src/proto/vtadmin.js | 22 ------- 6 files changed, 44 insertions(+), 124 deletions(-) diff --git a/go/mysql/replication_status.go b/go/mysql/replication_status.go index 201c88a426c..fb2a0f242d7 100644 --- a/go/mysql/replication_status.go +++ b/go/mysql/replication_status.go @@ -75,7 +75,7 @@ func (s *ReplicationStatus) SQLHealthy() bool { // ReplicationStatusToProto translates a Status to proto3. func ReplicationStatusToProto(s ReplicationStatus) *replicationdatapb.Status { - replstatus := replicationdatapb.Status{ + return &replicationdatapb.Status{ Position: EncodePosition(s.Position), RelayLogPosition: EncodePosition(s.RelayLogPosition), FilePosition: EncodePosition(s.FilePosition), @@ -86,18 +86,11 @@ func ReplicationStatusToProto(s ReplicationStatus) *replicationdatapb.Status { SourcePort: int32(s.SourcePort), ConnectRetry: int32(s.ConnectRetry), SourceUuid: s.SourceUUID.String(), + IoState: int32(s.IOState), LastIoError: s.LastIOError, + SqlState: int32(s.SQLState), LastSqlError: s.LastSQLError, } - if s.IOState == ReplicationStateRunning { - replstatus.IoThreadRunning = true - } else if s.IOState == ReplicationStateConnecting { - replstatus.IoThreadConnecting = true - } - if s.SQLState == ReplicationStateRunning { - replstatus.SqlThreadRunning = true - } - return &replstatus } // ProtoToReplicationStatus translates a proto Status, or panics. @@ -136,18 +129,21 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { SourcePort: int(s.SourcePort), ConnectRetry: int(s.ConnectRetry), SourceUUID: sid, - } - if s.IoThreadRunning { - replstatus.IOState = ReplicationStateRunning - } else if s.IoThreadConnecting { - replstatus.IOState = ReplicationStateConnecting - } else { - replstatus.IOState = ReplicationStateStopped - } - if s.SqlThreadRunning { - replstatus.SQLState = ReplicationStateRunning - } else { - replstatus.SQLState = ReplicationStateStopped + IOState: ReplicationState(s.IoState), + LastIOError: s.LastIoError, + SQLState: ReplicationState(s.SqlState), + LastSQLError: s.LastSqlError, + } + // We need to be able to process gRPC response messages from v13 and older tablets. + // In those cases there will be no value (uknown) for the IoState but the message + // will have the IoThreadRunning boolean and we need to revert to our assumptions + // about a binary state as that's all the older tablet can provide. + if s.IoState == int32(ReplicationStateUnknown) { + if s.IoThreadRunning { + replstatus.IOState = ReplicationStateRunning + } else { + replstatus.IOState = ReplicationStateStopped + } } return replstatus } diff --git a/go/vt/proto/replicationdata/replicationdata.pb.go b/go/vt/proto/replicationdata/replicationdata.pb.go index 8053a800127..ea787626223 100644 --- a/go/vt/proto/replicationdata/replicationdata.pb.go +++ b/go/vt/proto/replicationdata/replicationdata.pb.go @@ -93,8 +93,8 @@ type Status struct { Position string `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` // These fields should be removed in Vitess 15+ and fully replaced by the io_state and sql_state fields - // reserved 2, 3, 17; - // reserved "io_thread_running", "sql_thread_running", "io_thread_connecting"; + // reserved 2, 3; + // reserved "io_thread_running", "sql_thread_running"; IoThreadRunning bool `protobuf:"varint,2,opt,name=io_thread_running,json=ioThreadRunning,proto3" json:"io_thread_running,omitempty"` SqlThreadRunning bool `protobuf:"varint,3,opt,name=sql_thread_running,json=sqlThreadRunning,proto3" json:"sql_thread_running,omitempty"` ReplicationLagSeconds uint32 `protobuf:"varint,4,opt,name=replication_lag_seconds,json=replicationLagSeconds,proto3" json:"replication_lag_seconds,omitempty"` @@ -111,7 +111,6 @@ type Status struct { LastIoError string `protobuf:"bytes,14,opt,name=last_io_error,json=lastIoError,proto3" json:"last_io_error,omitempty"` SqlState int32 `protobuf:"varint,15,opt,name=sql_state,json=sqlState,proto3" json:"sql_state,omitempty"` LastSqlError string `protobuf:"bytes,16,opt,name=last_sql_error,json=lastSqlError,proto3" json:"last_sql_error,omitempty"` - IoThreadConnecting bool `protobuf:"varint,17,opt,name=io_thread_connecting,json=ioThreadConnecting,proto3" json:"io_thread_connecting,omitempty"` } func (x *Status) Reset() { @@ -258,13 +257,6 @@ func (x *Status) GetLastSqlError() string { return "" } -func (x *Status) GetIoThreadConnecting() bool { - if x != nil { - return x.IoThreadConnecting - } - return false -} - // StopReplicationStatus represents the replication status before calling StopReplication, and the replication status collected immediately after // calling StopReplication. type StopReplicationStatus struct { @@ -383,7 +375,7 @@ var File_replicationdata_proto protoreflect.FileDescriptor var file_replicationdata_proto_rawDesc = []byte{ 0x0a, 0x15, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa6, 0x05, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x22, 0xf4, 0x04, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6e, @@ -422,31 +414,27 @@ var file_replicationdata_proto_rawDesc = []byte{ 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x71, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x71, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, - 0x30, 0x0a, 0x14, 0x69, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x63, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x69, - 0x6f, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6e, - 0x67, 0x22, 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, - 0x66, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x61, - 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x50, 0x72, - 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x66, 0x69, 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3b, 0x0a, 0x13, - 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, - 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x4f, 0x41, 0x4e, 0x44, 0x53, 0x51, 0x4c, 0x54, - 0x48, 0x52, 0x45, 0x41, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x4f, 0x54, 0x48, 0x52, - 0x45, 0x41, 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x01, 0x42, 0x2e, 0x5a, 0x2c, 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, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x71, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, + 0x77, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, + 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x61, 0x66, 0x74, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x6d, + 0x61, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, + 0x6c, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x3b, 0x0a, 0x13, 0x53, 0x74, + 0x6f, 0x70, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, + 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x4f, 0x41, 0x4e, 0x44, 0x53, 0x51, 0x4c, 0x54, 0x48, 0x52, + 0x45, 0x41, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x4f, 0x54, 0x48, 0x52, 0x45, 0x41, + 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x01, 0x42, 0x2e, 0x5a, 0x2c, 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, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go index f42a15091bc..e928b53e79e 100644 --- a/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go +++ b/go/vt/proto/replicationdata/replicationdata_vtproto.pb.go @@ -48,18 +48,6 @@ func (m *Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if m.IoThreadConnecting { - i-- - if m.IoThreadConnecting { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x88 - } if len(m.LastSqlError) > 0 { i -= len(m.LastSqlError) copy(dAtA[i:], m.LastSqlError) @@ -344,9 +332,6 @@ func (m *Status) SizeVT() (n int) { if l > 0 { n += 2 + l + sov(uint64(l)) } - if m.IoThreadConnecting { - n += 3 - } if m.unknownFields != nil { n += len(m.unknownFields) } @@ -838,26 +823,6 @@ func (m *Status) UnmarshalVT(dAtA []byte) error { } m.LastSqlError = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 17: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IoThreadConnecting", 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.IoThreadConnecting = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/proto/replicationdata.proto b/proto/replicationdata.proto index f6bb8df1a06..f62b63b5c9e 100644 --- a/proto/replicationdata.proto +++ b/proto/replicationdata.proto @@ -26,8 +26,8 @@ package replicationdata; message Status { string position = 1; // These fields should be removed in Vitess 15+ and fully replaced by the io_state and sql_state fields - // reserved 2, 3, 17; - // reserved "io_thread_running", "sql_thread_running", "io_thread_connecting"; + // reserved 2, 3; + // reserved "io_thread_running", "sql_thread_running"; bool io_thread_running = 2; bool sql_thread_running = 3; uint32 replication_lag_seconds = 4; @@ -44,7 +44,6 @@ message Status { string last_io_error = 14; int32 sql_state = 15; string last_sql_error = 16; - bool io_thread_connecting = 17; } // StopReplicationStatus represents the replication status before calling StopReplication, and the replication status collected immediately after diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 57fcb758727..d331f9eff3c 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -26904,9 +26904,6 @@ export namespace replicationdata { /** Status last_sql_error */ last_sql_error?: (string|null); - - /** Status io_thread_connecting */ - io_thread_connecting?: (boolean|null); } /** Represents a Status. */ @@ -26966,9 +26963,6 @@ export namespace replicationdata { /** Status last_sql_error. */ public last_sql_error: string; - /** Status io_thread_connecting. */ - public io_thread_connecting: boolean; - /** * Creates a new Status 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 5df8e60eb33..e7661676c18 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -63287,7 +63287,6 @@ $root.replicationdata = (function() { * @property {string|null} [last_io_error] Status last_io_error * @property {number|null} [sql_state] Status sql_state * @property {string|null} [last_sql_error] Status last_sql_error - * @property {boolean|null} [io_thread_connecting] Status io_thread_connecting */ /** @@ -63433,14 +63432,6 @@ $root.replicationdata = (function() { */ Status.prototype.last_sql_error = ""; - /** - * Status io_thread_connecting. - * @member {boolean} io_thread_connecting - * @memberof replicationdata.Status - * @instance - */ - Status.prototype.io_thread_connecting = false; - /** * Creates a new Status instance using the specified properties. * @function create @@ -63497,8 +63488,6 @@ $root.replicationdata = (function() { writer.uint32(/* id 15, wireType 0 =*/120).int32(message.sql_state); if (message.last_sql_error != null && Object.hasOwnProperty.call(message, "last_sql_error")) writer.uint32(/* id 16, wireType 2 =*/130).string(message.last_sql_error); - if (message.io_thread_connecting != null && Object.hasOwnProperty.call(message, "io_thread_connecting")) - writer.uint32(/* id 17, wireType 0 =*/136).bool(message.io_thread_connecting); return writer; }; @@ -63581,9 +63570,6 @@ $root.replicationdata = (function() { case 16: message.last_sql_error = reader.string(); break; - case 17: - message.io_thread_connecting = reader.bool(); - break; default: reader.skipType(tag & 7); break; @@ -63667,9 +63653,6 @@ $root.replicationdata = (function() { if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) if (!$util.isString(message.last_sql_error)) return "last_sql_error: string expected"; - if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) - if (typeof message.io_thread_connecting !== "boolean") - return "io_thread_connecting: boolean expected"; return null; }; @@ -63717,8 +63700,6 @@ $root.replicationdata = (function() { message.sql_state = object.sql_state | 0; if (object.last_sql_error != null) message.last_sql_error = String(object.last_sql_error); - if (object.io_thread_connecting != null) - message.io_thread_connecting = Boolean(object.io_thread_connecting); return message; }; @@ -63752,7 +63733,6 @@ $root.replicationdata = (function() { object.last_io_error = ""; object.sql_state = 0; object.last_sql_error = ""; - object.io_thread_connecting = false; } if (message.position != null && message.hasOwnProperty("position")) object.position = message.position; @@ -63786,8 +63766,6 @@ $root.replicationdata = (function() { object.sql_state = message.sql_state; if (message.last_sql_error != null && message.hasOwnProperty("last_sql_error")) object.last_sql_error = message.last_sql_error; - if (message.io_thread_connecting != null && message.hasOwnProperty("io_thread_connecting")) - object.io_thread_connecting = message.io_thread_connecting; return object; }; From 841f1ccad84ee4524e58e7c4f6d4d9bd08b440c8 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 17:38:11 -0400 Subject: [PATCH 05/14] Continue using replication states in v14 tests Signed-off-by: Matt Lord --- go/vt/vtadmin/cluster/cluster_test.go | 37 ++++++++-------- .../reparentutil/emergency_reparenter_test.go | 44 +++++++++---------- go/vt/vtctl/reparentutil/replication.go | 2 +- go/vt/vtctl/reparentutil/replication_test.go | 16 +++---- go/vt/vttablet/tmrpctest/test_tm_rpc.go | 6 ++- 5 files changed, 54 insertions(+), 51 deletions(-) diff --git a/go/vt/vtadmin/cluster/cluster_test.go b/go/vt/vtadmin/cluster/cluster_test.go index aa9d9d5b646..38293064cc2 100644 --- a/go/vt/vtadmin/cluster/cluster_test.go +++ b/go/vt/vtadmin/cluster/cluster_test.go @@ -29,6 +29,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/util/sets" + "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/protoutil" "vitess.io/vitess/go/test/utils" "vitess.io/vitess/go/vt/topo" @@ -2426,19 +2427,19 @@ func TestGetShardReplicationPositions(t *testing.T) { Response: &vtctldatapb.ShardReplicationPositionsResponse{ ReplicationStatuses: map[string]*replicationdatapb.Status{ "zone1-001": { - IoThreadRunning: false, - SqlThreadRunning: false, - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-002": { // Note: in reality other fields will be set on replicating hosts as well, but this is sufficient to illustrate in the testing. - IoThreadRunning: true, - SqlThreadRunning: true, - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-003": { - IoThreadRunning: true, - SqlThreadRunning: true, - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, }, TabletMap: map[string]*topodatapb.Tablet{ @@ -2489,19 +2490,19 @@ func TestGetShardReplicationPositions(t *testing.T) { PositionInfo: &vtctldatapb.ShardReplicationPositionsResponse{ ReplicationStatuses: map[string]*replicationdatapb.Status{ "zone1-001": { - IoThreadRunning: false, - SqlThreadRunning: false, - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-002": { - IoThreadRunning: true, - SqlThreadRunning: true, - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, "zone1-003": { - IoThreadRunning: true, - SqlThreadRunning: true, - Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), + Position: "MySQL56/08d0dbbb-be29-11eb-9fea-0aafb9701138:1-109848265", }, }, TabletMap: map[string]*topodatapb.Tablet{ diff --git a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go index 9055588bd44..746c3c70d88 100644 --- a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go +++ b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go @@ -2038,14 +2038,14 @@ func TestEmergencyReparenter_promoteNewPrimary(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, }, @@ -2416,14 +2416,14 @@ func TestEmergencyReparenter_promoteNewPrimary(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, }, @@ -3229,14 +3229,14 @@ func TestEmergencyReparenter_reparentReplicas(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, }, @@ -3622,14 +3622,14 @@ func TestEmergencyReparenter_promoteIntermediateSource(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, }, @@ -3896,14 +3896,14 @@ func TestEmergencyReparenter_promoteIntermediateSource(t *testing.T) { statusMap: map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { // forceStart = false Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), }, }, "zone1-0000000102": { // forceStart = true Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, }, @@ -4242,8 +4242,8 @@ func TestParentContextCancelled(t *testing.T) { statusMap := map[string]*replicationdatapb.StopReplicationStatus{ "zone1-0000000101": { Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, } diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index ca5337bbbfe..a98053f829e 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -150,7 +150,7 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) } - return stopStatus.Before.IoThreadRunning || stopStatus.Before.SqlThreadRunning, nil + return stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning), nil } // SetReplicationSource is used to set the replication source on the specified diff --git a/go/vt/vtctl/reparentutil/replication_test.go b/go/vt/vtctl/reparentutil/replication_test.go index d50c0487769..13f25295599 100644 --- a/go/vt/vtctl/reparentutil/replication_test.go +++ b/go/vt/vtctl/reparentutil/replication_test.go @@ -1098,8 +1098,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "io thread running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateStopped), }, }, expected: true, @@ -1109,8 +1109,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "sql thread running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateRunning), }, }, expected: true, @@ -1120,8 +1120,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "io and sql threads running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), }, }, expected: true, @@ -1131,8 +1131,8 @@ func TestReplicaWasRunning(t *testing.T) { name: "no replication threads running", in: &replicationdatapb.StopReplicationStatus{ Before: &replicationdatapb.Status{ - IoThreadRunning: false, - SqlThreadRunning: false, + IoState: int32(mysql.ReplicationStateStopped), + SqlState: int32(mysql.ReplicationStateStopped), }, }, expected: false, diff --git a/go/vt/vttablet/tmrpctest/test_tm_rpc.go b/go/vt/vttablet/tmrpctest/test_tm_rpc.go index 9d7531aa551..ed0c338868e 100644 --- a/go/vt/vttablet/tmrpctest/test_tm_rpc.go +++ b/go/vt/vttablet/tmrpctest/test_tm_rpc.go @@ -25,6 +25,8 @@ import ( "testing" "time" + "vitess.io/vitess/go/mysql" + "context" "google.golang.org/protobuf/proto" @@ -684,8 +686,8 @@ func tmRPCTestExecuteFetchPanic(ctx context.Context, t *testing.T, client tmclie var testReplicationStatus = &replicationdatapb.Status{ Position: "MariaDB/1-345-789", - IoThreadRunning: true, - SqlThreadRunning: true, + IoState: int32(mysql.ReplicationStateRunning), + SqlState: int32(mysql.ReplicationStateRunning), ReplicationLagSeconds: 654, SourceHost: "source.host", SourcePort: 3366, From dd34bdc6f9054106c70aecd85f818d886e75f49d Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 17:59:20 -0400 Subject: [PATCH 06/14] Translate SQL running status to state as well Signed-off-by: Matt Lord --- go/mysql/replication_status.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/go/mysql/replication_status.go b/go/mysql/replication_status.go index fb2a0f242d7..7e894b39b14 100644 --- a/go/mysql/replication_status.go +++ b/go/mysql/replication_status.go @@ -134,10 +134,13 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { SQLState: ReplicationState(s.SqlState), LastSQLError: s.LastSqlError, } + // We need to be able to process gRPC response messages from v13 and older tablets. - // In those cases there will be no value (uknown) for the IoState but the message - // will have the IoThreadRunning boolean and we need to revert to our assumptions - // about a binary state as that's all the older tablet can provide. + // In those cases there will be no value (uknown) for the IoState or SqlState but + // the message will have the IoThreadRunning and SqlThreadRunning booleans and we + // need to revert to our assumptions about a binary state as that's all the older + // tablet can provide (really only applicable to the IO status as that is NOT binary + // but rather has three states: Running, Stopped, Connecting). if s.IoState == int32(ReplicationStateUnknown) { if s.IoThreadRunning { replstatus.IOState = ReplicationStateRunning @@ -145,6 +148,14 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { replstatus.IOState = ReplicationStateStopped } } + if s.SqlState == int32(ReplicationStateUnknown) { + if s.SqlThreadRunning { + replstatus.SQLState = ReplicationStateRunning + } else { + replstatus.SQLState = ReplicationStateStopped + } + } + return replstatus } From 06fcc84b859a668e00d627b8ba72fe3a1adf47c3 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 22:47:32 -0400 Subject: [PATCH 07/14] Use backward compat ReplicaWasRunning check Signed-off-by: Matt Lord --- go/mysql/replication_status.go | 4 ++-- go/vt/vtctl/reparentutil/replication.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/go/mysql/replication_status.go b/go/mysql/replication_status.go index 7e894b39b14..2447dbc3c04 100644 --- a/go/mysql/replication_status.go +++ b/go/mysql/replication_status.go @@ -141,14 +141,14 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { // need to revert to our assumptions about a binary state as that's all the older // tablet can provide (really only applicable to the IO status as that is NOT binary // but rather has three states: Running, Stopped, Connecting). - if s.IoState == int32(ReplicationStateUnknown) { + if replstatus.IOState == ReplicationStateUnknown { if s.IoThreadRunning { replstatus.IOState = ReplicationStateRunning } else { replstatus.IOState = ReplicationStateStopped } } - if s.SqlState == int32(ReplicationStateUnknown) { + if replstatus.SQLState == ReplicationStateUnknown { if s.SqlThreadRunning { replstatus.SQLState = ReplicationStateRunning } else { diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index a98053f829e..d3e229118ec 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -150,7 +150,11 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) } - return stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning), nil + // v13 and older tablets will only provide the binary IoThreadRunning and + // SqlThreadRunning values while v14 and newer tablets will provide the + // non-binary replication states + return ((stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.IoThreadRunning) || + (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning)), nil } // SetReplicationSource is used to set the replication source on the specified From 613da125bb48b2d06b7d7eb494523d5096a5c99a Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 22:57:34 -0400 Subject: [PATCH 08/14] Add backward compat SQLThreadWasRunning function Signed-off-by: Matt Lord --- go/vt/vtctl/reparentutil/replication.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index d3e229118ec..4f5945356ba 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -152,11 +152,26 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo // v13 and older tablets will only provide the binary IoThreadRunning and // SqlThreadRunning values while v14 and newer tablets will provide the - // non-binary replication states + // non-binary replication states. + // This backwards compatible check can be removed in v15. return ((stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.IoThreadRunning) || (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning)), nil } +// SQLThreadWasRunning returns true if a StopReplicationStatus indicates that the +// replica had a running sql thread. It returns an error if the Before state of +// replication is nil. +func SQLThreadWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (bool, error) { + if stopStatus == nil || stopStatus.Before == nil { + return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) + } + + // v13 and older tablets will only provide the binary SqlThreadRunning value + // while v14 and newer tablets will provide the non-binary replication states. + // This backwards compatible check can be removed in v15. + return (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning), nil +} + // SetReplicationSource is used to set the replication source on the specified // tablet to the current shard primary (if available). It also figures out if // the tablet should be sending semi-sync ACKs or not and passes that to the From e340dfcfac4e883464b391264552f506e17431dd Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 28 Apr 2022 23:02:06 -0400 Subject: [PATCH 09/14] Add comment about when backward compat can be removed Signed-off-by: Matt Lord --- go/mysql/replication_status.go | 3 ++- go/vt/vtctl/reparentutil/replication.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go/mysql/replication_status.go b/go/mysql/replication_status.go index 2447dbc3c04..c45c8c59114 100644 --- a/go/mysql/replication_status.go +++ b/go/mysql/replication_status.go @@ -136,11 +136,12 @@ func ProtoToReplicationStatus(s *replicationdatapb.Status) ReplicationStatus { } // We need to be able to process gRPC response messages from v13 and older tablets. - // In those cases there will be no value (uknown) for the IoState or SqlState but + // In those cases there will be no value (unknown) for the IoState or SqlState but // the message will have the IoThreadRunning and SqlThreadRunning booleans and we // need to revert to our assumptions about a binary state as that's all the older // tablet can provide (really only applicable to the IO status as that is NOT binary // but rather has three states: Running, Stopped, Connecting). + // This backwards compatibility can be removed in v15+. if replstatus.IOState == ReplicationStateUnknown { if s.IoThreadRunning { replstatus.IOState = ReplicationStateRunning diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index 4f5945356ba..713059d4f87 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -153,7 +153,7 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo // v13 and older tablets will only provide the binary IoThreadRunning and // SqlThreadRunning values while v14 and newer tablets will provide the // non-binary replication states. - // This backwards compatible check can be removed in v15. + // This backwards compatible check can be removed in v15+. return ((stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.IoThreadRunning) || (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning)), nil } @@ -168,7 +168,7 @@ func SQLThreadWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (b // v13 and older tablets will only provide the binary SqlThreadRunning value // while v14 and newer tablets will provide the non-binary replication states. - // This backwards compatible check can be removed in v15. + // This backwards compatible check can be removed in v15+. return (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning), nil } From c300f63c46845f8b38bd6b157fc5b134db39cbb3 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 29 Apr 2022 02:11:44 -0400 Subject: [PATCH 10/14] Support older clients with new tablets Signed-off-by: Matt Lord --- go/mysql/replication_status.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/go/mysql/replication_status.go b/go/mysql/replication_status.go index c45c8c59114..689992ce822 100644 --- a/go/mysql/replication_status.go +++ b/go/mysql/replication_status.go @@ -75,7 +75,7 @@ func (s *ReplicationStatus) SQLHealthy() bool { // ReplicationStatusToProto translates a Status to proto3. func ReplicationStatusToProto(s ReplicationStatus) *replicationdatapb.Status { - return &replicationdatapb.Status{ + replstatuspb := &replicationdatapb.Status{ Position: EncodePosition(s.Position), RelayLogPosition: EncodePosition(s.RelayLogPosition), FilePosition: EncodePosition(s.FilePosition), @@ -91,6 +91,21 @@ func ReplicationStatusToProto(s ReplicationStatus) *replicationdatapb.Status { SqlState: int32(s.SQLState), LastSqlError: s.LastSQLError, } + + // We need to be able to send gRPC response messages from v14 and newer tablets to + // v13 and older clients. The older clients will not be processing the IoState or + // SqlState values in the message but instead looking at the IoThreadRunning and + // SqlThreadRunning booleans so we need to map and share this dual state. + // Note: v13 and older clients considered the IO thread state of connecting to + // be equal to running. That is why we do so here when mapping the states. + // This backwards compatibility can be removed in v15+. + if s.IOState == ReplicationStateRunning || s.IOState == ReplicationStateConnecting { + replstatuspb.IoThreadRunning = true + } + if s.SQLState == ReplicationStateRunning { + replstatuspb.SqlThreadRunning = true + } + return replstatuspb } // ProtoToReplicationStatus translates a proto Status, or panics. From c76f6e90c95130a03b143e0b74318fdcbac35e94 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 29 Apr 2022 12:41:16 +0530 Subject: [PATCH 11/14] feat: remove SQLThreadWasRunning unused function Signed-off-by: Manan Gupta --- go/vt/vtctl/reparentutil/replication.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index 713059d4f87..a62a45b2ddd 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -158,20 +158,6 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning)), nil } -// SQLThreadWasRunning returns true if a StopReplicationStatus indicates that the -// replica had a running sql thread. It returns an error if the Before state of -// replication is nil. -func SQLThreadWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (bool, error) { - if stopStatus == nil || stopStatus.Before == nil { - return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) - } - - // v13 and older tablets will only provide the binary SqlThreadRunning value - // while v14 and newer tablets will provide the non-binary replication states. - // This backwards compatible check can be removed in v15+. - return (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning), nil -} - // SetReplicationSource is used to set the replication source on the specified // tablet to the current shard primary (if available). It also figures out if // the tablet should be sending semi-sync ACKs or not and passes that to the From 1717e383a3b6b6ae5853952d9ee7aef11f6b2954 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 29 Apr 2022 12:43:04 +0530 Subject: [PATCH 12/14] test: add an upgrade test to verify the replicationstatus is backward compatible Signed-off-by: Manan Gupta --- go/test/endtoend/cluster/cluster_util.go | 11 +++++ .../reparent/plannedreparent/reparent_test.go | 41 +++++++++++++++++++ go/test/endtoend/reparent/utils/utils.go | 36 ++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/go/test/endtoend/cluster/cluster_util.go b/go/test/endtoend/cluster/cluster_util.go index 0e1ed5957f2..7975a26d99e 100644 --- a/go/test/endtoend/cluster/cluster_util.go +++ b/go/test/endtoend/cluster/cluster_util.go @@ -24,6 +24,8 @@ import ( "testing" "time" + replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -86,6 +88,15 @@ func GetPrimaryPosition(t *testing.T, vttablet Vttablet, hostname string) (strin return pos, gtID } +// GetReplicationPosition gets the replication status of given vttablet +func GetReplicationPosition(t *testing.T, vttablet *Vttablet, hostname string) *replicationdatapb.Status { + ctx := context.Background() + vtablet := getTablet(vttablet.GrpcPort, hostname) + pos, err := tmClient.ReplicationStatus(ctx, vtablet) + require.NoError(t, err) + return pos +} + // VerifyRowsInTabletForTable verifies the total number of rows in a table. // This is used to check that replication has caught up with the changes on primary. func VerifyRowsInTabletForTable(t *testing.T, vttablet *Vttablet, ksName string, expectedRows int, tableName string) { diff --git a/go/test/endtoend/reparent/plannedreparent/reparent_test.go b/go/test/endtoend/reparent/plannedreparent/reparent_test.go index ca903e8f799..9d447018d2b 100644 --- a/go/test/endtoend/reparent/plannedreparent/reparent_test.go +++ b/go/test/endtoend/reparent/plannedreparent/reparent_test.go @@ -378,3 +378,44 @@ func TestReparentDoesntHangIfPrimaryFails(t *testing.T) { require.Error(t, err) assert.Contains(t, out, "primary failed to PopulateReparentJournal") } + +func TestReplicationStatus(t *testing.T) { + defer cluster.PanicHandler(t) + clusterInstance := utils.SetupReparentCluster(t, true) + defer utils.TeardownCluster(clusterInstance) + tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets + utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]}) + + // Stop the SQL_THREAD on tablets[1] + err := clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `STOP SLAVE SQL_THREAD;`) + require.NoError(t, err) + // Check the replication status on tablets[1] and assert that the IO thread is read to be running and SQL thread is stopped + replicationStatus := cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + ioThread, sqlThread := utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) + require.True(t, ioThread) + require.False(t, sqlThread) + + // Stop replication on tablets[1] and verify that both the threads are reported as not running + err = clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `STOP SLAVE;`) + require.NoError(t, err) + replicationStatus = cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + ioThread, sqlThread = utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) + require.False(t, ioThread) + require.False(t, sqlThread) + + // Start replication on tablets[1] and verify that both the threads are reported as running + err = clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `START SLAVE;`) + require.NoError(t, err) + replicationStatus = cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + ioThread, sqlThread = utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) + require.True(t, ioThread) + require.True(t, sqlThread) + + // Stop IO_THREAD on tablets[1] and verify that the IO thread is read to be stopped and SQL thread is running + err = clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `STOP SLAVE IO_THREAD;`) + require.NoError(t, err) + replicationStatus = cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + ioThread, sqlThread = utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) + require.False(t, ioThread) + require.True(t, sqlThread) +} diff --git a/go/test/endtoend/reparent/utils/utils.go b/go/test/endtoend/reparent/utils/utils.go index ed6b823b618..34172157037 100644 --- a/go/test/endtoend/reparent/utils/utils.go +++ b/go/test/endtoend/reparent/utils/utils.go @@ -34,6 +34,7 @@ import ( "vitess.io/vitess/go/json2" "vitess.io/vitess/go/vt/log" querypb "vitess.io/vitess/go/vt/proto/query" + replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata" topodatapb "vitess.io/vitess/go/vt/proto/topodata" "vitess.io/vitess/go/mysql" @@ -744,3 +745,38 @@ func CheckReplicationStatus(ctx context.Context, t *testing.T, tablet *cluster.V require.Equal(t, "No", res.Rows[0][11].ToString()) } } + +// ReplicationThreadsStatus returns the status of the IO and SQL thread. It reads the result of the replication status +// based on the vtctl major version provided. It also uses the vttabletVersion to assert on the expectation of the new fields +// being unknown for the old vttablets and that they match for the new vttablets +func ReplicationThreadsStatus(t *testing.T, status *replicationdatapb.Status, vtctlVersion, vttabletVersion int) (bool, bool) { + if vttabletVersion == 13 { + // If vttablet is version 13, then the new fields should be unknown + require.Equal(t, mysql.ReplicationStateUnknown, mysql.ReplicationState(status.IoState)) + require.Equal(t, mysql.ReplicationStateUnknown, mysql.ReplicationState(status.SqlState)) + } else { + // For the new vttablet, the new parameters should not be unknown. Moreover, the old parameters should also be provided + // and should agree with the new ones + require.NotEqual(t, mysql.ReplicationStateUnknown, mysql.ReplicationState(status.IoState)) + require.NotEqual(t, mysql.ReplicationStateUnknown, mysql.ReplicationState(status.SqlState)) + require.Equal(t, status.IoThreadRunning, mysql.ReplicationState(status.IoState) == mysql.ReplicationStateRunning) + require.Equal(t, status.SqlThreadRunning, mysql.ReplicationState(status.SqlState) == mysql.ReplicationStateRunning) + } + + // if vtctlVersion provided is 13, then we should read the old parameters, since that is what old vtctl would do + if vtctlVersion == 13 { + return status.IoThreadRunning, status.SqlThreadRunning + } + // If we are at the latest vtctl version, we should read the latest parameters if provided otherwise the old ones + ioState := mysql.ReplicationState(status.IoState) + ioThread := status.IoThreadRunning + if ioState != mysql.ReplicationStateUnknown { + ioThread = ioState == mysql.ReplicationStateRunning + } + sqlState := mysql.ReplicationState(status.SqlState) + sqlThread := status.SqlThreadRunning + if sqlState != mysql.ReplicationStateUnknown { + sqlThread = sqlState == mysql.ReplicationStateRunning + } + return ioThread, sqlThread +} From 65369fe3fe386408dbc7cc7c476cdb7bcdda2ab2 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 29 Apr 2022 13:29:54 +0530 Subject: [PATCH 13/14] feat: fix ReplicaWasRunning so that it doesn't have code dependent on the upgrade Signed-off-by: Manan Gupta --- go/vt/vtctl/reparentutil/replication.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index a62a45b2ddd..63403f7c70e 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -150,12 +150,9 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) } - // v13 and older tablets will only provide the binary IoThreadRunning and - // SqlThreadRunning values while v14 and newer tablets will provide the - // non-binary replication states. - // This backwards compatible check can be removed in v15+. - return ((stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.IoThreadRunning) || - (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning)), nil + replStatus := mysql.ProtoToReplicationStatus(stopStatus.Before) + return (replStatus.IOState == mysql.ReplicationStateRunning) || + (replStatus.SQLState == mysql.ReplicationStateRunning), nil } // SetReplicationSource is used to set the replication source on the specified From 2a3af2405b521616fcf77f434394be82b7f203a7 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 29 Apr 2022 21:34:11 +0530 Subject: [PATCH 14/14] refactor: rename function to reflect the output type Signed-off-by: Manan Gupta --- go/test/endtoend/cluster/cluster_util.go | 4 ++-- .../endtoend/reparent/plannedreparent/reparent_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/test/endtoend/cluster/cluster_util.go b/go/test/endtoend/cluster/cluster_util.go index 7975a26d99e..8098c1623ee 100644 --- a/go/test/endtoend/cluster/cluster_util.go +++ b/go/test/endtoend/cluster/cluster_util.go @@ -88,8 +88,8 @@ func GetPrimaryPosition(t *testing.T, vttablet Vttablet, hostname string) (strin return pos, gtID } -// GetReplicationPosition gets the replication status of given vttablet -func GetReplicationPosition(t *testing.T, vttablet *Vttablet, hostname string) *replicationdatapb.Status { +// GetReplicationStatus gets the replication status of given vttablet +func GetReplicationStatus(t *testing.T, vttablet *Vttablet, hostname string) *replicationdatapb.Status { ctx := context.Background() vtablet := getTablet(vttablet.GrpcPort, hostname) pos, err := tmClient.ReplicationStatus(ctx, vtablet) diff --git a/go/test/endtoend/reparent/plannedreparent/reparent_test.go b/go/test/endtoend/reparent/plannedreparent/reparent_test.go index 9d447018d2b..74749f21c7e 100644 --- a/go/test/endtoend/reparent/plannedreparent/reparent_test.go +++ b/go/test/endtoend/reparent/plannedreparent/reparent_test.go @@ -390,7 +390,7 @@ func TestReplicationStatus(t *testing.T) { err := clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `STOP SLAVE SQL_THREAD;`) require.NoError(t, err) // Check the replication status on tablets[1] and assert that the IO thread is read to be running and SQL thread is stopped - replicationStatus := cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + replicationStatus := cluster.GetReplicationStatus(t, tablets[1], utils.Hostname) ioThread, sqlThread := utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) require.True(t, ioThread) require.False(t, sqlThread) @@ -398,7 +398,7 @@ func TestReplicationStatus(t *testing.T) { // Stop replication on tablets[1] and verify that both the threads are reported as not running err = clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `STOP SLAVE;`) require.NoError(t, err) - replicationStatus = cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + replicationStatus = cluster.GetReplicationStatus(t, tablets[1], utils.Hostname) ioThread, sqlThread = utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) require.False(t, ioThread) require.False(t, sqlThread) @@ -406,7 +406,7 @@ func TestReplicationStatus(t *testing.T) { // Start replication on tablets[1] and verify that both the threads are reported as running err = clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `START SLAVE;`) require.NoError(t, err) - replicationStatus = cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + replicationStatus = cluster.GetReplicationStatus(t, tablets[1], utils.Hostname) ioThread, sqlThread = utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) require.True(t, ioThread) require.True(t, sqlThread) @@ -414,7 +414,7 @@ func TestReplicationStatus(t *testing.T) { // Stop IO_THREAD on tablets[1] and verify that the IO thread is read to be stopped and SQL thread is running err = clusterInstance.VtctlclientProcess.ExecuteCommand("ExecuteFetchAsDba", tablets[1].Alias, `STOP SLAVE IO_THREAD;`) require.NoError(t, err) - replicationStatus = cluster.GetReplicationPosition(t, tablets[1], utils.Hostname) + replicationStatus = cluster.GetReplicationStatus(t, tablets[1], utils.Hostname) ioThread, sqlThread = utils.ReplicationThreadsStatus(t, replicationStatus, clusterInstance.VtctlMajorVersion, clusterInstance.VtTabletMajorVersion) require.False(t, ioThread) require.True(t, sqlThread)