diff --git a/go/test/endtoend/vtorc/general/vtorc_test.go b/go/test/endtoend/vtorc/general/vtorc_test.go index 844085a007d..1dabfc3a9f3 100644 --- a/go/test/endtoend/vtorc/general/vtorc_test.go +++ b/go/test/endtoend/vtorc/general/vtorc_test.go @@ -31,8 +31,8 @@ import ( "vitess.io/vitess/go/test/endtoend/vtorc/utils" "vitess.io/vitess/go/vt/log" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" vtutils "vitess.io/vitess/go/vt/utils" - "vitess.io/vitess/go/vt/vtorc/inst" "vitess.io/vitess/go/vt/vtorc/logic" ) @@ -317,7 +317,7 @@ func TestVTOrcRepairs(t *testing.T) { // Wait for problems to be set. utils.WaitForDetectedProblems(t, vtOrcProcess, - string(inst.PrimaryIsReadOnly), + vtorcdatapb.AnalysisType_PrimaryIsReadOnly, curPrimary.Alias, keyspace.Name, shard0.Name, @@ -331,7 +331,7 @@ func TestVTOrcRepairs(t *testing.T) { // wait for detected problem to be cleared. utils.WaitForDetectedProblems(t, vtOrcProcess, - string(inst.PrimaryIsReadOnly), + vtorcdatapb.AnalysisType_PrimaryIsReadOnly, curPrimary.Alias, keyspace.Name, shard0.Name, diff --git a/go/test/endtoend/vtorc/utils/utils.go b/go/test/endtoend/vtorc/utils/utils.go index caca923b1e2..b6af7966430 100644 --- a/go/test/endtoend/vtorc/utils/utils.go +++ b/go/test/endtoend/vtorc/utils/utils.go @@ -38,10 +38,12 @@ import ( "vitess.io/vitess/go/test/endtoend/cluster" "vitess.io/vitess/go/vt/log" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/utils" "vitess.io/vitess/go/vt/vtctl/reparentutil/policy" + "vitess.io/vitess/go/vt/vtorc/inst" // Register topo implementations. _ "vitess.io/vitess/go/vt/topo/consultopo" @@ -1080,9 +1082,9 @@ func GetIntFromValue(val any) int { } // WaitForDetectedProblems waits until the given analysis code, alias, keyspace and shard count matches the count expected. -func WaitForDetectedProblems(t *testing.T, vtorcInstance *cluster.VTOrcProcess, code, alias, ks, shard string, expect int) { +func WaitForDetectedProblems(t *testing.T, vtorcInstance *cluster.VTOrcProcess, analysisType vtorcdatapb.AnalysisType, alias, ks, shard string, expect int) { t.Helper() - key := strings.Join([]string{code, alias, ks, shard}, ".") + key := strings.Join([]string{inst.AnalysisTypeProtoToString(analysisType), alias, ks, shard}, ".") timeout := 15 * time.Second startTime := time.Now() diff --git a/go/vt/proto/vtorcdata/vtorcdata.pb.go b/go/vt/proto/vtorcdata/vtorcdata.pb.go new file mode 100644 index 00000000000..f8a39780677 --- /dev/null +++ b/go/vt/proto/vtorcdata/vtorcdata.pb.go @@ -0,0 +1,1008 @@ +// +//Copyright 2025 The Vitess Authors. +// +//Licensed under the Apache License, Version 2.0 (the "License"); +//you may not use this file except in compliance with the License. +//You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, software +//distributed under the License is distributed on an "AS IS" BASIS, +//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +//See the License for the specific language governing permissions and +//limitations under the License. + +// This file defines the replication related structures we use. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v3.21.3 +// source: vtorcdata.proto + +package vtorcdata + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" + topodata "vitess.io/vitess/go/vt/proto/topodata" + vttime "vitess.io/vitess/go/vt/proto/vttime" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AnalysisType int32 + +const ( + AnalysisType_NoProblem AnalysisType = 0 + AnalysisType_ClusterHasNoPrimary AnalysisType = 1 + AnalysisType_PrimaryTabletDeleted AnalysisType = 2 + AnalysisType_InvalidPrimary AnalysisType = 3 + AnalysisType_InvalidReplica AnalysisType = 4 + AnalysisType_DeadPrimaryWithoutReplicas AnalysisType = 5 + AnalysisType_DeadPrimary AnalysisType = 6 + AnalysisType_DeadPrimaryAndReplicas AnalysisType = 7 + AnalysisType_DeadPrimaryAndSomeReplicas AnalysisType = 8 + AnalysisType_PrimaryHasPrimary AnalysisType = 9 + AnalysisType_PrimaryIsReadOnly AnalysisType = 10 + AnalysisType_PrimaryCurrentTypeMismatch AnalysisType = 11 + AnalysisType_PrimarySemiSyncMustBeSet AnalysisType = 12 + AnalysisType_PrimarySemiSyncMustNotBeSet AnalysisType = 13 + AnalysisType_ReplicaIsWritable AnalysisType = 14 + AnalysisType_NotConnectedToPrimary AnalysisType = 15 + AnalysisType_ConnectedToWrongPrimary AnalysisType = 16 + AnalysisType_ReplicationStopped AnalysisType = 17 + AnalysisType_ReplicaSemiSyncMustBeSet AnalysisType = 18 + AnalysisType_ReplicaSemiSyncMustNotBeSet AnalysisType = 19 + AnalysisType_ReplicaMisconfigured AnalysisType = 20 + AnalysisType_UnreachablePrimaryWithLaggingReplicas AnalysisType = 21 + AnalysisType_UnreachablePrimary AnalysisType = 22 + AnalysisType_PrimarySingleReplicaNotReplicating AnalysisType = 23 + AnalysisType_PrimarySingleReplicaDead AnalysisType = 24 + AnalysisType_AllPrimaryReplicasNotReplicating AnalysisType = 25 + AnalysisType_AllPrimaryReplicasNotReplicatingOrDead AnalysisType = 26 + AnalysisType_LockedSemiSyncPrimaryHypothesis AnalysisType = 27 + AnalysisType_LockedSemiSyncPrimary AnalysisType = 28 + AnalysisType_PrimarySemiSyncBlocked AnalysisType = 29 + AnalysisType_ErrantGtidDetected AnalysisType = 30 + AnalysisType_PrimaryDiskStalled AnalysisType = 31 +) + +// Enum value maps for AnalysisType. +var ( + AnalysisType_name = map[int32]string{ + 0: "NoProblem", + 1: "ClusterHasNoPrimary", + 2: "PrimaryTabletDeleted", + 3: "InvalidPrimary", + 4: "InvalidReplica", + 5: "DeadPrimaryWithoutReplicas", + 6: "DeadPrimary", + 7: "DeadPrimaryAndReplicas", + 8: "DeadPrimaryAndSomeReplicas", + 9: "PrimaryHasPrimary", + 10: "PrimaryIsReadOnly", + 11: "PrimaryCurrentTypeMismatch", + 12: "PrimarySemiSyncMustBeSet", + 13: "PrimarySemiSyncMustNotBeSet", + 14: "ReplicaIsWritable", + 15: "NotConnectedToPrimary", + 16: "ConnectedToWrongPrimary", + 17: "ReplicationStopped", + 18: "ReplicaSemiSyncMustBeSet", + 19: "ReplicaSemiSyncMustNotBeSet", + 20: "ReplicaMisconfigured", + 21: "UnreachablePrimaryWithLaggingReplicas", + 22: "UnreachablePrimary", + 23: "PrimarySingleReplicaNotReplicating", + 24: "PrimarySingleReplicaDead", + 25: "AllPrimaryReplicasNotReplicating", + 26: "AllPrimaryReplicasNotReplicatingOrDead", + 27: "LockedSemiSyncPrimaryHypothesis", + 28: "LockedSemiSyncPrimary", + 29: "PrimarySemiSyncBlocked", + 30: "ErrantGtidDetected", + 31: "PrimaryDiskStalled", + } + AnalysisType_value = map[string]int32{ + "NoProblem": 0, + "ClusterHasNoPrimary": 1, + "PrimaryTabletDeleted": 2, + "InvalidPrimary": 3, + "InvalidReplica": 4, + "DeadPrimaryWithoutReplicas": 5, + "DeadPrimary": 6, + "DeadPrimaryAndReplicas": 7, + "DeadPrimaryAndSomeReplicas": 8, + "PrimaryHasPrimary": 9, + "PrimaryIsReadOnly": 10, + "PrimaryCurrentTypeMismatch": 11, + "PrimarySemiSyncMustBeSet": 12, + "PrimarySemiSyncMustNotBeSet": 13, + "ReplicaIsWritable": 14, + "NotConnectedToPrimary": 15, + "ConnectedToWrongPrimary": 16, + "ReplicationStopped": 17, + "ReplicaSemiSyncMustBeSet": 18, + "ReplicaSemiSyncMustNotBeSet": 19, + "ReplicaMisconfigured": 20, + "UnreachablePrimaryWithLaggingReplicas": 21, + "UnreachablePrimary": 22, + "PrimarySingleReplicaNotReplicating": 23, + "PrimarySingleReplicaDead": 24, + "AllPrimaryReplicasNotReplicating": 25, + "AllPrimaryReplicasNotReplicatingOrDead": 26, + "LockedSemiSyncPrimaryHypothesis": 27, + "LockedSemiSyncPrimary": 28, + "PrimarySemiSyncBlocked": 29, + "ErrantGtidDetected": 30, + "PrimaryDiskStalled": 31, + } +) + +func (x AnalysisType) Enum() *AnalysisType { + p := new(AnalysisType) + *p = x + return p +} + +func (x AnalysisType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AnalysisType) Descriptor() protoreflect.EnumDescriptor { + return file_vtorcdata_proto_enumTypes[0].Descriptor() +} + +func (AnalysisType) Type() protoreflect.EnumType { + return &file_vtorcdata_proto_enumTypes[0] +} + +func (x AnalysisType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AnalysisType.Descriptor instead. +func (AnalysisType) EnumDescriptor() ([]byte, []int) { + return file_vtorcdata_proto_rawDescGZIP(), []int{0} +} + +type StructureAnalysisType int32 + +const ( + StructureAnalysisType_NoStructureAnalysis StructureAnalysisType = 0 + StructureAnalysisType_StatementAndMixedLoggingReplicasStructureWarning StructureAnalysisType = 1 + StructureAnalysisType_StatementAndRowLoggingReplicasStructureWarning StructureAnalysisType = 2 + StructureAnalysisType_MixedAndRowLoggingReplicasStructureWarning StructureAnalysisType = 3 + StructureAnalysisType_MultipleMajorVersionsLoggingReplicasStructureWarning StructureAnalysisType = 4 + StructureAnalysisType_NoLoggingReplicasStructureWarning StructureAnalysisType = 5 + StructureAnalysisType_DifferentGtidModesStructureWarning StructureAnalysisType = 6 + StructureAnalysisType_ErrantGtidStructureWarning StructureAnalysisType = 7 + StructureAnalysisType_NoFailoverSupportStructureWarning StructureAnalysisType = 8 + StructureAnalysisType_NoWriteablePrimaryStructureWarning StructureAnalysisType = 9 + StructureAnalysisType_NotEnoughValidSemiSyncReplicasStructureWarning StructureAnalysisType = 10 +) + +// Enum value maps for StructureAnalysisType. +var ( + StructureAnalysisType_name = map[int32]string{ + 0: "NoStructureAnalysis", + 1: "StatementAndMixedLoggingReplicasStructureWarning", + 2: "StatementAndRowLoggingReplicasStructureWarning", + 3: "MixedAndRowLoggingReplicasStructureWarning", + 4: "MultipleMajorVersionsLoggingReplicasStructureWarning", + 5: "NoLoggingReplicasStructureWarning", + 6: "DifferentGtidModesStructureWarning", + 7: "ErrantGtidStructureWarning", + 8: "NoFailoverSupportStructureWarning", + 9: "NoWriteablePrimaryStructureWarning", + 10: "NotEnoughValidSemiSyncReplicasStructureWarning", + } + StructureAnalysisType_value = map[string]int32{ + "NoStructureAnalysis": 0, + "StatementAndMixedLoggingReplicasStructureWarning": 1, + "StatementAndRowLoggingReplicasStructureWarning": 2, + "MixedAndRowLoggingReplicasStructureWarning": 3, + "MultipleMajorVersionsLoggingReplicasStructureWarning": 4, + "NoLoggingReplicasStructureWarning": 5, + "DifferentGtidModesStructureWarning": 6, + "ErrantGtidStructureWarning": 7, + "NoFailoverSupportStructureWarning": 8, + "NoWriteablePrimaryStructureWarning": 9, + "NotEnoughValidSemiSyncReplicasStructureWarning": 10, + } +) + +func (x StructureAnalysisType) Enum() *StructureAnalysisType { + p := new(StructureAnalysisType) + *p = x + return p +} + +func (x StructureAnalysisType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (StructureAnalysisType) Descriptor() protoreflect.EnumDescriptor { + return file_vtorcdata_proto_enumTypes[1].Descriptor() +} + +func (StructureAnalysisType) Type() protoreflect.EnumType { + return &file_vtorcdata_proto_enumTypes[1] +} + +func (x StructureAnalysisType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use StructureAnalysisType.Descriptor instead. +func (StructureAnalysisType) EnumDescriptor() ([]byte, []int) { + return file_vtorcdata_proto_rawDescGZIP(), []int{1} +} + +type GTIDMode int32 + +const ( + GTIDMode_OFF GTIDMode = 0 + GTIDMode_OFF_PERMISSIVE GTIDMode = 1 + GTIDMode_ON_PERMISSIVE GTIDMode = 2 + GTIDMode_ON GTIDMode = 3 +) + +// Enum value maps for GTIDMode. +var ( + GTIDMode_name = map[int32]string{ + 0: "OFF", + 1: "OFF_PERMISSIVE", + 2: "ON_PERMISSIVE", + 3: "ON", + } + GTIDMode_value = map[string]int32{ + "OFF": 0, + "OFF_PERMISSIVE": 1, + "ON_PERMISSIVE": 2, + "ON": 3, + } +) + +func (x GTIDMode) Enum() *GTIDMode { + p := new(GTIDMode) + *p = x + return p +} + +func (x GTIDMode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (GTIDMode) Descriptor() protoreflect.EnumDescriptor { + return file_vtorcdata_proto_enumTypes[2].Descriptor() +} + +func (GTIDMode) Type() protoreflect.EnumType { + return &file_vtorcdata_proto_enumTypes[2] +} + +func (x GTIDMode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use GTIDMode.Descriptor instead. +func (GTIDMode) EnumDescriptor() ([]byte, []int) { + return file_vtorcdata_proto_rawDescGZIP(), []int{2} +} + +type BinlogType int32 + +const ( + BinlogType_BinaryLog BinlogType = 0 + BinlogType_RelayLog BinlogType = 1 +) + +// Enum value maps for BinlogType. +var ( + BinlogType_name = map[int32]string{ + 0: "BinaryLog", + 1: "RelayLog", + } + BinlogType_value = map[string]int32{ + "BinaryLog": 0, + "RelayLog": 1, + } +) + +func (x BinlogType) Enum() *BinlogType { + p := new(BinlogType) + *p = x + return p +} + +func (x BinlogType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (BinlogType) Descriptor() protoreflect.EnumDescriptor { + return file_vtorcdata_proto_enumTypes[3].Descriptor() +} + +func (BinlogType) Type() protoreflect.EnumType { + return &file_vtorcdata_proto_enumTypes[3] +} + +func (x BinlogType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use BinlogType.Descriptor instead. +func (BinlogType) EnumDescriptor() ([]byte, []int) { + return file_vtorcdata_proto_rawDescGZIP(), []int{3} +} + +type BinlogCoordinates struct { + state protoimpl.MessageState `protogen:"open.v1"` + LogFile string `protobuf:"bytes,1,opt,name=LogFile,proto3" json:"LogFile,omitempty"` + LogPos uint64 `protobuf:"varint,2,opt,name=LogPos,proto3" json:"LogPos,omitempty"` + Type BinlogType `protobuf:"varint,3,opt,name=type,proto3,enum=vtorcdata.BinlogType" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BinlogCoordinates) Reset() { + *x = BinlogCoordinates{} + mi := &file_vtorcdata_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BinlogCoordinates) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BinlogCoordinates) ProtoMessage() {} + +func (x *BinlogCoordinates) ProtoReflect() protoreflect.Message { + mi := &file_vtorcdata_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BinlogCoordinates.ProtoReflect.Descriptor instead. +func (*BinlogCoordinates) Descriptor() ([]byte, []int) { + return file_vtorcdata_proto_rawDescGZIP(), []int{0} +} + +func (x *BinlogCoordinates) GetLogFile() string { + if x != nil { + return x.LogFile + } + return "" +} + +func (x *BinlogCoordinates) GetLogPos() uint64 { + if x != nil { + return x.LogPos + } + return 0 +} + +func (x *BinlogCoordinates) GetType() BinlogType { + if x != nil { + return x.Type + } + return BinlogType_BinaryLog +} + +type ReplicationAnalysis struct { + state protoimpl.MessageState `protogen:"open.v1"` + RecoveryId int64 `protobuf:"varint,1,opt,name=recovery_id,json=recoveryId,proto3" json:"recovery_id,omitempty"` + AnalyzedInstanceAlias string `protobuf:"bytes,2,opt,name=analyzed_instance_alias,json=analyzedInstanceAlias,proto3" json:"analyzed_instance_alias,omitempty"` + AnalyzedInstancePrimaryAlias string `protobuf:"bytes,3,opt,name=analyzed_instance_primary_alias,json=analyzedInstancePrimaryAlias,proto3" json:"analyzed_instance_primary_alias,omitempty"` + AnalyzedKeyspace string `protobuf:"bytes,4,opt,name=analyzed_keyspace,json=analyzedKeyspace,proto3" json:"analyzed_keyspace,omitempty"` + AnalyzedShard string `protobuf:"bytes,5,opt,name=analyzed_shard,json=analyzedShard,proto3" json:"analyzed_shard,omitempty"` + TabletType topodata.TabletType `protobuf:"varint,6,opt,name=tablet_type,json=tabletType,proto3,enum=topodata.TabletType" json:"tablet_type,omitempty"` + CurrentTabletType topodata.TabletType `protobuf:"varint,7,opt,name=current_tablet_type,json=currentTabletType,proto3,enum=topodata.TabletType" json:"current_tablet_type,omitempty"` + PrimaryTimestamp *vttime.Time `protobuf:"bytes,8,opt,name=primary_timestamp,json=primaryTimestamp,proto3" json:"primary_timestamp,omitempty"` + ShardPrimaryTermTimestamp *vttime.Time `protobuf:"bytes,9,opt,name=shard_primary_term_timestamp,json=shardPrimaryTermTimestamp,proto3" json:"shard_primary_term_timestamp,omitempty"` + AnalyzedInstanceBinlogCoordinates *BinlogCoordinates `protobuf:"bytes,10,opt,name=analyzed_instance_binlog_coordinates,json=analyzedInstanceBinlogCoordinates,proto3" json:"analyzed_instance_binlog_coordinates,omitempty"` + IsPrimary bool `protobuf:"varint,11,opt,name=is_primary,json=isPrimary,proto3" json:"is_primary,omitempty"` + IsClusterPrimary bool `protobuf:"varint,12,opt,name=is_cluster_primary,json=isClusterPrimary,proto3" json:"is_cluster_primary,omitempty"` + IsReadOnly bool `protobuf:"varint,13,opt,name=is_read_only,json=isReadOnly,proto3" json:"is_read_only,omitempty"` + IsDiskStalled bool `protobuf:"varint,14,opt,name=is_disk_stalled,json=isDiskStalled,proto3" json:"is_disk_stalled,omitempty"` + IsActionableRecovery bool `protobuf:"varint,15,opt,name=is_actionable_recovery,json=isActionableRecovery,proto3" json:"is_actionable_recovery,omitempty"` + LastCheckValid bool `protobuf:"varint,16,opt,name=last_check_valid,json=lastCheckValid,proto3" json:"last_check_valid,omitempty"` + LastCheckPartialSuccess bool `protobuf:"varint,17,opt,name=last_check_partial_success,json=lastCheckPartialSuccess,proto3" json:"last_check_partial_success,omitempty"` + ReplicationStopped bool `protobuf:"varint,18,opt,name=replication_stopped,json=replicationStopped,proto3" json:"replication_stopped,omitempty"` + GtidMode GTIDMode `protobuf:"varint,19,opt,name=gtid_mode,json=gtidMode,proto3,enum=vtorcdata.GTIDMode" json:"gtid_mode,omitempty"` + MinReplicaGtidMode GTIDMode `protobuf:"varint,20,opt,name=min_replica_gtid_mode,json=minReplicaGtidMode,proto3,enum=vtorcdata.GTIDMode" json:"min_replica_gtid_mode,omitempty"` + MaxReplicaGtidMode GTIDMode `protobuf:"varint,21,opt,name=max_replica_gtid_mode,json=maxReplicaGtidMode,proto3,enum=vtorcdata.GTIDMode" json:"max_replica_gtid_mode,omitempty"` + ErrantGtid string `protobuf:"bytes,22,opt,name=errant_gtid,json=errantGtid,proto3" json:"errant_gtid,omitempty"` + MaxReplicaErrantGtid string `protobuf:"bytes,23,opt,name=max_replica_errant_gtid,json=maxReplicaErrantGtid,proto3" json:"max_replica_errant_gtid,omitempty"` + ReplicaNetTimeout int32 `protobuf:"varint,24,opt,name=replica_net_timeout,json=replicaNetTimeout,proto3" json:"replica_net_timeout,omitempty"` + HeartbeatInterval float32 `protobuf:"fixed32,25,opt,name=heartbeat_interval,json=heartbeatInterval,proto3" json:"heartbeat_interval,omitempty"` + Analysis AnalysisType `protobuf:"varint,26,opt,name=analysis,proto3,enum=vtorcdata.AnalysisType" json:"analysis,omitempty"` + Description string `protobuf:"bytes,27,opt,name=description,proto3" json:"description,omitempty"` + StructureAnalysis []StructureAnalysisType `protobuf:"varint,28,rep,packed,name=structure_analysis,json=structureAnalysis,proto3,enum=vtorcdata.StructureAnalysisType" json:"structure_analysis,omitempty"` + OracleGtidImmediateTopology bool `protobuf:"varint,29,opt,name=oracle_gtid_immediate_topology,json=oracleGtidImmediateTopology,proto3" json:"oracle_gtid_immediate_topology,omitempty"` + BinlogServerImmediateTopology bool `protobuf:"varint,30,opt,name=binlog_server_immediate_topology,json=binlogServerImmediateTopology,proto3" json:"binlog_server_immediate_topology,omitempty"` + SemiSyncPrimaryEnabled bool `protobuf:"varint,31,opt,name=semi_sync_primary_enabled,json=semiSyncPrimaryEnabled,proto3" json:"semi_sync_primary_enabled,omitempty"` + SemiSyncPrimaryStatus bool `protobuf:"varint,32,opt,name=semi_sync_primary_status,json=semiSyncPrimaryStatus,proto3" json:"semi_sync_primary_status,omitempty"` + SemiSyncReplicaEnabled bool `protobuf:"varint,33,opt,name=semi_sync_replica_enabled,json=semiSyncReplicaEnabled,proto3" json:"semi_sync_replica_enabled,omitempty"` + SemiSyncBlocked bool `protobuf:"varint,34,opt,name=semi_sync_blocked,json=semiSyncBlocked,proto3" json:"semi_sync_blocked,omitempty"` + CountReplicas uint32 `protobuf:"varint,35,opt,name=count_replicas,json=countReplicas,proto3" json:"count_replicas,omitempty"` + CountValidReplicas uint32 `protobuf:"varint,36,opt,name=count_valid_replicas,json=countValidReplicas,proto3" json:"count_valid_replicas,omitempty"` + CountValidReplicatingReplicas uint32 `protobuf:"varint,37,opt,name=count_valid_replicating_replicas,json=countValidReplicatingReplicas,proto3" json:"count_valid_replicating_replicas,omitempty"` + CountSemiSyncPrimaryWaitForReplica uint32 `protobuf:"varint,38,opt,name=count_semi_sync_primary_wait_for_replica,json=countSemiSyncPrimaryWaitForReplica,proto3" json:"count_semi_sync_primary_wait_for_replica,omitempty"` + CountSemiSyncPrimaryClients uint32 `protobuf:"varint,39,opt,name=count_semi_sync_primary_clients,json=countSemiSyncPrimaryClients,proto3" json:"count_semi_sync_primary_clients,omitempty"` + CountSemiSyncReplicasEnabled uint32 `protobuf:"varint,40,opt,name=count_semi_sync_replicas_enabled,json=countSemiSyncReplicasEnabled,proto3" json:"count_semi_sync_replicas_enabled,omitempty"` + CountLoggingReplicas uint32 `protobuf:"varint,41,opt,name=count_logging_replicas,json=countLoggingReplicas,proto3" json:"count_logging_replicas,omitempty"` + CountStatementBasedLoggingReplicas uint32 `protobuf:"varint,42,opt,name=count_statement_based_logging_replicas,json=countStatementBasedLoggingReplicas,proto3" json:"count_statement_based_logging_replicas,omitempty"` + CountMixedBasedLoggingReplicas uint32 `protobuf:"varint,43,opt,name=count_mixed_based_logging_replicas,json=countMixedBasedLoggingReplicas,proto3" json:"count_mixed_based_logging_replicas,omitempty"` + CountRowBasedLoggingReplicas uint32 `protobuf:"varint,44,opt,name=count_row_based_logging_replicas,json=countRowBasedLoggingReplicas,proto3" json:"count_row_based_logging_replicas,omitempty"` + CountDistinctMajorVersionsLoggingReplicas uint32 `protobuf:"varint,45,opt,name=count_distinct_major_versions_logging_replicas,json=countDistinctMajorVersionsLoggingReplicas,proto3" json:"count_distinct_major_versions_logging_replicas,omitempty"` + CountDelayedReplicas uint32 `protobuf:"varint,46,opt,name=count_delayed_replicas,json=countDelayedReplicas,proto3" json:"count_delayed_replicas,omitempty"` + CountLaggingReplicas uint32 `protobuf:"varint,47,opt,name=count_lagging_replicas,json=countLaggingReplicas,proto3" json:"count_lagging_replicas,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReplicationAnalysis) Reset() { + *x = ReplicationAnalysis{} + mi := &file_vtorcdata_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReplicationAnalysis) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReplicationAnalysis) ProtoMessage() {} + +func (x *ReplicationAnalysis) ProtoReflect() protoreflect.Message { + mi := &file_vtorcdata_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReplicationAnalysis.ProtoReflect.Descriptor instead. +func (*ReplicationAnalysis) Descriptor() ([]byte, []int) { + return file_vtorcdata_proto_rawDescGZIP(), []int{1} +} + +func (x *ReplicationAnalysis) GetRecoveryId() int64 { + if x != nil { + return x.RecoveryId + } + return 0 +} + +func (x *ReplicationAnalysis) GetAnalyzedInstanceAlias() string { + if x != nil { + return x.AnalyzedInstanceAlias + } + return "" +} + +func (x *ReplicationAnalysis) GetAnalyzedInstancePrimaryAlias() string { + if x != nil { + return x.AnalyzedInstancePrimaryAlias + } + return "" +} + +func (x *ReplicationAnalysis) GetAnalyzedKeyspace() string { + if x != nil { + return x.AnalyzedKeyspace + } + return "" +} + +func (x *ReplicationAnalysis) GetAnalyzedShard() string { + if x != nil { + return x.AnalyzedShard + } + return "" +} + +func (x *ReplicationAnalysis) GetTabletType() topodata.TabletType { + if x != nil { + return x.TabletType + } + return topodata.TabletType(0) +} + +func (x *ReplicationAnalysis) GetCurrentTabletType() topodata.TabletType { + if x != nil { + return x.CurrentTabletType + } + return topodata.TabletType(0) +} + +func (x *ReplicationAnalysis) GetPrimaryTimestamp() *vttime.Time { + if x != nil { + return x.PrimaryTimestamp + } + return nil +} + +func (x *ReplicationAnalysis) GetShardPrimaryTermTimestamp() *vttime.Time { + if x != nil { + return x.ShardPrimaryTermTimestamp + } + return nil +} + +func (x *ReplicationAnalysis) GetAnalyzedInstanceBinlogCoordinates() *BinlogCoordinates { + if x != nil { + return x.AnalyzedInstanceBinlogCoordinates + } + return nil +} + +func (x *ReplicationAnalysis) GetIsPrimary() bool { + if x != nil { + return x.IsPrimary + } + return false +} + +func (x *ReplicationAnalysis) GetIsClusterPrimary() bool { + if x != nil { + return x.IsClusterPrimary + } + return false +} + +func (x *ReplicationAnalysis) GetIsReadOnly() bool { + if x != nil { + return x.IsReadOnly + } + return false +} + +func (x *ReplicationAnalysis) GetIsDiskStalled() bool { + if x != nil { + return x.IsDiskStalled + } + return false +} + +func (x *ReplicationAnalysis) GetIsActionableRecovery() bool { + if x != nil { + return x.IsActionableRecovery + } + return false +} + +func (x *ReplicationAnalysis) GetLastCheckValid() bool { + if x != nil { + return x.LastCheckValid + } + return false +} + +func (x *ReplicationAnalysis) GetLastCheckPartialSuccess() bool { + if x != nil { + return x.LastCheckPartialSuccess + } + return false +} + +func (x *ReplicationAnalysis) GetReplicationStopped() bool { + if x != nil { + return x.ReplicationStopped + } + return false +} + +func (x *ReplicationAnalysis) GetGtidMode() GTIDMode { + if x != nil { + return x.GtidMode + } + return GTIDMode_OFF +} + +func (x *ReplicationAnalysis) GetMinReplicaGtidMode() GTIDMode { + if x != nil { + return x.MinReplicaGtidMode + } + return GTIDMode_OFF +} + +func (x *ReplicationAnalysis) GetMaxReplicaGtidMode() GTIDMode { + if x != nil { + return x.MaxReplicaGtidMode + } + return GTIDMode_OFF +} + +func (x *ReplicationAnalysis) GetErrantGtid() string { + if x != nil { + return x.ErrantGtid + } + return "" +} + +func (x *ReplicationAnalysis) GetMaxReplicaErrantGtid() string { + if x != nil { + return x.MaxReplicaErrantGtid + } + return "" +} + +func (x *ReplicationAnalysis) GetReplicaNetTimeout() int32 { + if x != nil { + return x.ReplicaNetTimeout + } + return 0 +} + +func (x *ReplicationAnalysis) GetHeartbeatInterval() float32 { + if x != nil { + return x.HeartbeatInterval + } + return 0 +} + +func (x *ReplicationAnalysis) GetAnalysis() AnalysisType { + if x != nil { + return x.Analysis + } + return AnalysisType_NoProblem +} + +func (x *ReplicationAnalysis) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *ReplicationAnalysis) GetStructureAnalysis() []StructureAnalysisType { + if x != nil { + return x.StructureAnalysis + } + return nil +} + +func (x *ReplicationAnalysis) GetOracleGtidImmediateTopology() bool { + if x != nil { + return x.OracleGtidImmediateTopology + } + return false +} + +func (x *ReplicationAnalysis) GetBinlogServerImmediateTopology() bool { + if x != nil { + return x.BinlogServerImmediateTopology + } + return false +} + +func (x *ReplicationAnalysis) GetSemiSyncPrimaryEnabled() bool { + if x != nil { + return x.SemiSyncPrimaryEnabled + } + return false +} + +func (x *ReplicationAnalysis) GetSemiSyncPrimaryStatus() bool { + if x != nil { + return x.SemiSyncPrimaryStatus + } + return false +} + +func (x *ReplicationAnalysis) GetSemiSyncReplicaEnabled() bool { + if x != nil { + return x.SemiSyncReplicaEnabled + } + return false +} + +func (x *ReplicationAnalysis) GetSemiSyncBlocked() bool { + if x != nil { + return x.SemiSyncBlocked + } + return false +} + +func (x *ReplicationAnalysis) GetCountReplicas() uint32 { + if x != nil { + return x.CountReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountValidReplicas() uint32 { + if x != nil { + return x.CountValidReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountValidReplicatingReplicas() uint32 { + if x != nil { + return x.CountValidReplicatingReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountSemiSyncPrimaryWaitForReplica() uint32 { + if x != nil { + return x.CountSemiSyncPrimaryWaitForReplica + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountSemiSyncPrimaryClients() uint32 { + if x != nil { + return x.CountSemiSyncPrimaryClients + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountSemiSyncReplicasEnabled() uint32 { + if x != nil { + return x.CountSemiSyncReplicasEnabled + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountLoggingReplicas() uint32 { + if x != nil { + return x.CountLoggingReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountStatementBasedLoggingReplicas() uint32 { + if x != nil { + return x.CountStatementBasedLoggingReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountMixedBasedLoggingReplicas() uint32 { + if x != nil { + return x.CountMixedBasedLoggingReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountRowBasedLoggingReplicas() uint32 { + if x != nil { + return x.CountRowBasedLoggingReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountDistinctMajorVersionsLoggingReplicas() uint32 { + if x != nil { + return x.CountDistinctMajorVersionsLoggingReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountDelayedReplicas() uint32 { + if x != nil { + return x.CountDelayedReplicas + } + return 0 +} + +func (x *ReplicationAnalysis) GetCountLaggingReplicas() uint32 { + if x != nil { + return x.CountLaggingReplicas + } + return 0 +} + +var File_vtorcdata_proto protoreflect.FileDescriptor + +const file_vtorcdata_proto_rawDesc = "" + + "\n" + + "\x0fvtorcdata.proto\x12\tvtorcdata\x1a\x0etopodata.proto\x1a\fvttime.proto\"p\n" + + "\x11BinlogCoordinates\x12\x18\n" + + "\aLogFile\x18\x01 \x01(\tR\aLogFile\x12\x16\n" + + "\x06LogPos\x18\x02 \x01(\x04R\x06LogPos\x12)\n" + + "\x04type\x18\x03 \x01(\x0e2\x15.vtorcdata.BinlogTypeR\x04type\"\xe1\x15\n" + + "\x13ReplicationAnalysis\x12\x1f\n" + + "\vrecovery_id\x18\x01 \x01(\x03R\n" + + "recoveryId\x126\n" + + "\x17analyzed_instance_alias\x18\x02 \x01(\tR\x15analyzedInstanceAlias\x12E\n" + + "\x1fanalyzed_instance_primary_alias\x18\x03 \x01(\tR\x1canalyzedInstancePrimaryAlias\x12+\n" + + "\x11analyzed_keyspace\x18\x04 \x01(\tR\x10analyzedKeyspace\x12%\n" + + "\x0eanalyzed_shard\x18\x05 \x01(\tR\ranalyzedShard\x125\n" + + "\vtablet_type\x18\x06 \x01(\x0e2\x14.topodata.TabletTypeR\n" + + "tabletType\x12D\n" + + "\x13current_tablet_type\x18\a \x01(\x0e2\x14.topodata.TabletTypeR\x11currentTabletType\x129\n" + + "\x11primary_timestamp\x18\b \x01(\v2\f.vttime.TimeR\x10primaryTimestamp\x12M\n" + + "\x1cshard_primary_term_timestamp\x18\t \x01(\v2\f.vttime.TimeR\x19shardPrimaryTermTimestamp\x12m\n" + + "$analyzed_instance_binlog_coordinates\x18\n" + + " \x01(\v2\x1c.vtorcdata.BinlogCoordinatesR!analyzedInstanceBinlogCoordinates\x12\x1d\n" + + "\n" + + "is_primary\x18\v \x01(\bR\tisPrimary\x12,\n" + + "\x12is_cluster_primary\x18\f \x01(\bR\x10isClusterPrimary\x12 \n" + + "\fis_read_only\x18\r \x01(\bR\n" + + "isReadOnly\x12&\n" + + "\x0fis_disk_stalled\x18\x0e \x01(\bR\risDiskStalled\x124\n" + + "\x16is_actionable_recovery\x18\x0f \x01(\bR\x14isActionableRecovery\x12(\n" + + "\x10last_check_valid\x18\x10 \x01(\bR\x0elastCheckValid\x12;\n" + + "\x1alast_check_partial_success\x18\x11 \x01(\bR\x17lastCheckPartialSuccess\x12/\n" + + "\x13replication_stopped\x18\x12 \x01(\bR\x12replicationStopped\x120\n" + + "\tgtid_mode\x18\x13 \x01(\x0e2\x13.vtorcdata.GTIDModeR\bgtidMode\x12F\n" + + "\x15min_replica_gtid_mode\x18\x14 \x01(\x0e2\x13.vtorcdata.GTIDModeR\x12minReplicaGtidMode\x12F\n" + + "\x15max_replica_gtid_mode\x18\x15 \x01(\x0e2\x13.vtorcdata.GTIDModeR\x12maxReplicaGtidMode\x12\x1f\n" + + "\verrant_gtid\x18\x16 \x01(\tR\n" + + "errantGtid\x125\n" + + "\x17max_replica_errant_gtid\x18\x17 \x01(\tR\x14maxReplicaErrantGtid\x12.\n" + + "\x13replica_net_timeout\x18\x18 \x01(\x05R\x11replicaNetTimeout\x12-\n" + + "\x12heartbeat_interval\x18\x19 \x01(\x02R\x11heartbeatInterval\x123\n" + + "\banalysis\x18\x1a \x01(\x0e2\x17.vtorcdata.AnalysisTypeR\banalysis\x12 \n" + + "\vdescription\x18\x1b \x01(\tR\vdescription\x12O\n" + + "\x12structure_analysis\x18\x1c \x03(\x0e2 .vtorcdata.StructureAnalysisTypeR\x11structureAnalysis\x12C\n" + + "\x1eoracle_gtid_immediate_topology\x18\x1d \x01(\bR\x1boracleGtidImmediateTopology\x12G\n" + + " binlog_server_immediate_topology\x18\x1e \x01(\bR\x1dbinlogServerImmediateTopology\x129\n" + + "\x19semi_sync_primary_enabled\x18\x1f \x01(\bR\x16semiSyncPrimaryEnabled\x127\n" + + "\x18semi_sync_primary_status\x18 \x01(\bR\x15semiSyncPrimaryStatus\x129\n" + + "\x19semi_sync_replica_enabled\x18! \x01(\bR\x16semiSyncReplicaEnabled\x12*\n" + + "\x11semi_sync_blocked\x18\" \x01(\bR\x0fsemiSyncBlocked\x12%\n" + + "\x0ecount_replicas\x18# \x01(\rR\rcountReplicas\x120\n" + + "\x14count_valid_replicas\x18$ \x01(\rR\x12countValidReplicas\x12G\n" + + " count_valid_replicating_replicas\x18% \x01(\rR\x1dcountValidReplicatingReplicas\x12T\n" + + "(count_semi_sync_primary_wait_for_replica\x18& \x01(\rR\"countSemiSyncPrimaryWaitForReplica\x12D\n" + + "\x1fcount_semi_sync_primary_clients\x18' \x01(\rR\x1bcountSemiSyncPrimaryClients\x12F\n" + + " count_semi_sync_replicas_enabled\x18( \x01(\rR\x1ccountSemiSyncReplicasEnabled\x124\n" + + "\x16count_logging_replicas\x18) \x01(\rR\x14countLoggingReplicas\x12R\n" + + "&count_statement_based_logging_replicas\x18* \x01(\rR\"countStatementBasedLoggingReplicas\x12J\n" + + "\"count_mixed_based_logging_replicas\x18+ \x01(\rR\x1ecountMixedBasedLoggingReplicas\x12F\n" + + " count_row_based_logging_replicas\x18, \x01(\rR\x1ccountRowBasedLoggingReplicas\x12a\n" + + ".count_distinct_major_versions_logging_replicas\x18- \x01(\rR)countDistinctMajorVersionsLoggingReplicas\x124\n" + + "\x16count_delayed_replicas\x18. \x01(\rR\x14countDelayedReplicas\x124\n" + + "\x16count_lagging_replicas\x18/ \x01(\rR\x14countLaggingReplicas*\x99\a\n" + + "\fAnalysisType\x12\r\n" + + "\tNoProblem\x10\x00\x12\x17\n" + + "\x13ClusterHasNoPrimary\x10\x01\x12\x18\n" + + "\x14PrimaryTabletDeleted\x10\x02\x12\x12\n" + + "\x0eInvalidPrimary\x10\x03\x12\x12\n" + + "\x0eInvalidReplica\x10\x04\x12\x1e\n" + + "\x1aDeadPrimaryWithoutReplicas\x10\x05\x12\x0f\n" + + "\vDeadPrimary\x10\x06\x12\x1a\n" + + "\x16DeadPrimaryAndReplicas\x10\a\x12\x1e\n" + + "\x1aDeadPrimaryAndSomeReplicas\x10\b\x12\x15\n" + + "\x11PrimaryHasPrimary\x10\t\x12\x15\n" + + "\x11PrimaryIsReadOnly\x10\n" + + "\x12\x1e\n" + + "\x1aPrimaryCurrentTypeMismatch\x10\v\x12\x1c\n" + + "\x18PrimarySemiSyncMustBeSet\x10\f\x12\x1f\n" + + "\x1bPrimarySemiSyncMustNotBeSet\x10\r\x12\x15\n" + + "\x11ReplicaIsWritable\x10\x0e\x12\x19\n" + + "\x15NotConnectedToPrimary\x10\x0f\x12\x1b\n" + + "\x17ConnectedToWrongPrimary\x10\x10\x12\x16\n" + + "\x12ReplicationStopped\x10\x11\x12\x1c\n" + + "\x18ReplicaSemiSyncMustBeSet\x10\x12\x12\x1f\n" + + "\x1bReplicaSemiSyncMustNotBeSet\x10\x13\x12\x18\n" + + "\x14ReplicaMisconfigured\x10\x14\x12)\n" + + "%UnreachablePrimaryWithLaggingReplicas\x10\x15\x12\x16\n" + + "\x12UnreachablePrimary\x10\x16\x12&\n" + + "\"PrimarySingleReplicaNotReplicating\x10\x17\x12\x1c\n" + + "\x18PrimarySingleReplicaDead\x10\x18\x12$\n" + + " AllPrimaryReplicasNotReplicating\x10\x19\x12*\n" + + "&AllPrimaryReplicasNotReplicatingOrDead\x10\x1a\x12#\n" + + "\x1fLockedSemiSyncPrimaryHypothesis\x10\x1b\x12\x19\n" + + "\x15LockedSemiSyncPrimary\x10\x1c\x12\x1a\n" + + "\x16PrimarySemiSyncBlocked\x10\x1d\x12\x16\n" + + "\x12ErrantGtidDetected\x10\x1e\x12\x16\n" + + "\x12PrimaryDiskStalled\x10\x1f*\xf6\x03\n" + + "\x15StructureAnalysisType\x12\x17\n" + + "\x13NoStructureAnalysis\x10\x00\x124\n" + + "0StatementAndMixedLoggingReplicasStructureWarning\x10\x01\x122\n" + + ".StatementAndRowLoggingReplicasStructureWarning\x10\x02\x12.\n" + + "*MixedAndRowLoggingReplicasStructureWarning\x10\x03\x128\n" + + "4MultipleMajorVersionsLoggingReplicasStructureWarning\x10\x04\x12%\n" + + "!NoLoggingReplicasStructureWarning\x10\x05\x12&\n" + + "\"DifferentGtidModesStructureWarning\x10\x06\x12\x1e\n" + + "\x1aErrantGtidStructureWarning\x10\a\x12%\n" + + "!NoFailoverSupportStructureWarning\x10\b\x12&\n" + + "\"NoWriteablePrimaryStructureWarning\x10\t\x122\n" + + ".NotEnoughValidSemiSyncReplicasStructureWarning\x10\n" + + "*B\n" + + "\bGTIDMode\x12\a\n" + + "\x03OFF\x10\x00\x12\x12\n" + + "\x0eOFF_PERMISSIVE\x10\x01\x12\x11\n" + + "\rON_PERMISSIVE\x10\x02\x12\x06\n" + + "\x02ON\x10\x03*)\n" + + "\n" + + "BinlogType\x12\r\n" + + "\tBinaryLog\x10\x00\x12\f\n" + + "\bRelayLog\x10\x01B(Z&vitess.io/vitess/go/vt/proto/vtorcdatab\x06proto3" + +var ( + file_vtorcdata_proto_rawDescOnce sync.Once + file_vtorcdata_proto_rawDescData []byte +) + +func file_vtorcdata_proto_rawDescGZIP() []byte { + file_vtorcdata_proto_rawDescOnce.Do(func() { + file_vtorcdata_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_vtorcdata_proto_rawDesc), len(file_vtorcdata_proto_rawDesc))) + }) + return file_vtorcdata_proto_rawDescData +} + +var file_vtorcdata_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_vtorcdata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_vtorcdata_proto_goTypes = []any{ + (AnalysisType)(0), // 0: vtorcdata.AnalysisType + (StructureAnalysisType)(0), // 1: vtorcdata.StructureAnalysisType + (GTIDMode)(0), // 2: vtorcdata.GTIDMode + (BinlogType)(0), // 3: vtorcdata.BinlogType + (*BinlogCoordinates)(nil), // 4: vtorcdata.BinlogCoordinates + (*ReplicationAnalysis)(nil), // 5: vtorcdata.ReplicationAnalysis + (topodata.TabletType)(0), // 6: topodata.TabletType + (*vttime.Time)(nil), // 7: vttime.Time +} +var file_vtorcdata_proto_depIdxs = []int32{ + 3, // 0: vtorcdata.BinlogCoordinates.type:type_name -> vtorcdata.BinlogType + 6, // 1: vtorcdata.ReplicationAnalysis.tablet_type:type_name -> topodata.TabletType + 6, // 2: vtorcdata.ReplicationAnalysis.current_tablet_type:type_name -> topodata.TabletType + 7, // 3: vtorcdata.ReplicationAnalysis.primary_timestamp:type_name -> vttime.Time + 7, // 4: vtorcdata.ReplicationAnalysis.shard_primary_term_timestamp:type_name -> vttime.Time + 4, // 5: vtorcdata.ReplicationAnalysis.analyzed_instance_binlog_coordinates:type_name -> vtorcdata.BinlogCoordinates + 2, // 6: vtorcdata.ReplicationAnalysis.gtid_mode:type_name -> vtorcdata.GTIDMode + 2, // 7: vtorcdata.ReplicationAnalysis.min_replica_gtid_mode:type_name -> vtorcdata.GTIDMode + 2, // 8: vtorcdata.ReplicationAnalysis.max_replica_gtid_mode:type_name -> vtorcdata.GTIDMode + 0, // 9: vtorcdata.ReplicationAnalysis.analysis:type_name -> vtorcdata.AnalysisType + 1, // 10: vtorcdata.ReplicationAnalysis.structure_analysis:type_name -> vtorcdata.StructureAnalysisType + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name +} + +func init() { file_vtorcdata_proto_init() } +func file_vtorcdata_proto_init() { + if File_vtorcdata_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_vtorcdata_proto_rawDesc), len(file_vtorcdata_proto_rawDesc)), + NumEnums: 4, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_vtorcdata_proto_goTypes, + DependencyIndexes: file_vtorcdata_proto_depIdxs, + EnumInfos: file_vtorcdata_proto_enumTypes, + MessageInfos: file_vtorcdata_proto_msgTypes, + }.Build() + File_vtorcdata_proto = out.File + file_vtorcdata_proto_goTypes = nil + file_vtorcdata_proto_depIdxs = nil +} diff --git a/go/vt/proto/vtorcdata/vtorcdata_vtproto.pb.go b/go/vt/proto/vtorcdata/vtorcdata_vtproto.pb.go new file mode 100644 index 00000000000..8c4431ce114 --- /dev/null +++ b/go/vt/proto/vtorcdata/vtorcdata_vtproto.pb.go @@ -0,0 +1,2057 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20241121165744-79df5c4772f2 +// source: vtorcdata.proto + +package vtorcdata + +import ( + binary "encoding/binary" + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + math "math" + topodata "vitess.io/vitess/go/vt/proto/topodata" + vttime "vitess.io/vitess/go/vt/proto/vttime" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *BinlogCoordinates) CloneVT() *BinlogCoordinates { + if m == nil { + return (*BinlogCoordinates)(nil) + } + r := new(BinlogCoordinates) + r.LogFile = m.LogFile + r.LogPos = m.LogPos + r.Type = m.Type + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *BinlogCoordinates) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ReplicationAnalysis) CloneVT() *ReplicationAnalysis { + if m == nil { + return (*ReplicationAnalysis)(nil) + } + r := new(ReplicationAnalysis) + r.RecoveryId = m.RecoveryId + r.AnalyzedInstanceAlias = m.AnalyzedInstanceAlias + r.AnalyzedInstancePrimaryAlias = m.AnalyzedInstancePrimaryAlias + r.AnalyzedKeyspace = m.AnalyzedKeyspace + r.AnalyzedShard = m.AnalyzedShard + r.TabletType = m.TabletType + r.CurrentTabletType = m.CurrentTabletType + r.PrimaryTimestamp = m.PrimaryTimestamp.CloneVT() + r.ShardPrimaryTermTimestamp = m.ShardPrimaryTermTimestamp.CloneVT() + r.AnalyzedInstanceBinlogCoordinates = m.AnalyzedInstanceBinlogCoordinates.CloneVT() + r.IsPrimary = m.IsPrimary + r.IsClusterPrimary = m.IsClusterPrimary + r.IsReadOnly = m.IsReadOnly + r.IsDiskStalled = m.IsDiskStalled + r.IsActionableRecovery = m.IsActionableRecovery + r.LastCheckValid = m.LastCheckValid + r.LastCheckPartialSuccess = m.LastCheckPartialSuccess + r.ReplicationStopped = m.ReplicationStopped + r.GtidMode = m.GtidMode + r.MinReplicaGtidMode = m.MinReplicaGtidMode + r.MaxReplicaGtidMode = m.MaxReplicaGtidMode + r.ErrantGtid = m.ErrantGtid + r.MaxReplicaErrantGtid = m.MaxReplicaErrantGtid + r.ReplicaNetTimeout = m.ReplicaNetTimeout + r.HeartbeatInterval = m.HeartbeatInterval + r.Analysis = m.Analysis + r.Description = m.Description + r.OracleGtidImmediateTopology = m.OracleGtidImmediateTopology + r.BinlogServerImmediateTopology = m.BinlogServerImmediateTopology + r.SemiSyncPrimaryEnabled = m.SemiSyncPrimaryEnabled + r.SemiSyncPrimaryStatus = m.SemiSyncPrimaryStatus + r.SemiSyncReplicaEnabled = m.SemiSyncReplicaEnabled + r.SemiSyncBlocked = m.SemiSyncBlocked + r.CountReplicas = m.CountReplicas + r.CountValidReplicas = m.CountValidReplicas + r.CountValidReplicatingReplicas = m.CountValidReplicatingReplicas + r.CountSemiSyncPrimaryWaitForReplica = m.CountSemiSyncPrimaryWaitForReplica + r.CountSemiSyncPrimaryClients = m.CountSemiSyncPrimaryClients + r.CountSemiSyncReplicasEnabled = m.CountSemiSyncReplicasEnabled + r.CountLoggingReplicas = m.CountLoggingReplicas + r.CountStatementBasedLoggingReplicas = m.CountStatementBasedLoggingReplicas + r.CountMixedBasedLoggingReplicas = m.CountMixedBasedLoggingReplicas + r.CountRowBasedLoggingReplicas = m.CountRowBasedLoggingReplicas + r.CountDistinctMajorVersionsLoggingReplicas = m.CountDistinctMajorVersionsLoggingReplicas + r.CountDelayedReplicas = m.CountDelayedReplicas + r.CountLaggingReplicas = m.CountLaggingReplicas + if rhs := m.StructureAnalysis; rhs != nil { + tmpContainer := make([]StructureAnalysisType, len(rhs)) + copy(tmpContainer, rhs) + r.StructureAnalysis = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ReplicationAnalysis) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *BinlogCoordinates) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BinlogCoordinates) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *BinlogCoordinates) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Type != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x18 + } + if m.LogPos != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LogPos)) + i-- + dAtA[i] = 0x10 + } + if len(m.LogFile) > 0 { + i -= len(m.LogFile) + copy(dAtA[i:], m.LogFile) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.LogFile))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ReplicationAnalysis) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ReplicationAnalysis) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ReplicationAnalysis) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.CountLaggingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountLaggingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xf8 + } + if m.CountDelayedReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountDelayedReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xf0 + } + if m.CountDistinctMajorVersionsLoggingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountDistinctMajorVersionsLoggingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xe8 + } + if m.CountRowBasedLoggingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountRowBasedLoggingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xe0 + } + if m.CountMixedBasedLoggingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountMixedBasedLoggingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xd8 + } + if m.CountStatementBasedLoggingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountStatementBasedLoggingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xd0 + } + if m.CountLoggingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountLoggingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xc8 + } + if m.CountSemiSyncReplicasEnabled != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountSemiSyncReplicasEnabled)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xc0 + } + if m.CountSemiSyncPrimaryClients != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountSemiSyncPrimaryClients)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xb8 + } + if m.CountSemiSyncPrimaryWaitForReplica != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountSemiSyncPrimaryWaitForReplica)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xb0 + } + if m.CountValidReplicatingReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountValidReplicatingReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xa8 + } + if m.CountValidReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountValidReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xa0 + } + if m.CountReplicas != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CountReplicas)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x98 + } + if m.SemiSyncBlocked { + i-- + if m.SemiSyncBlocked { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x90 + } + if m.SemiSyncReplicaEnabled { + i-- + if m.SemiSyncReplicaEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x88 + } + if m.SemiSyncPrimaryStatus { + i-- + if m.SemiSyncPrimaryStatus { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x80 + } + if m.SemiSyncPrimaryEnabled { + i-- + if m.SemiSyncPrimaryEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xf8 + } + if m.BinlogServerImmediateTopology { + i-- + if m.BinlogServerImmediateTopology { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xf0 + } + if m.OracleGtidImmediateTopology { + i-- + if m.OracleGtidImmediateTopology { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xe8 + } + if len(m.StructureAnalysis) > 0 { + var pksize2 int + for _, num := range m.StructureAnalysis { + pksize2 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num1 := range m.StructureAnalysis { + num := uint64(num1) + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xe2 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xda + } + if m.Analysis != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Analysis)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd0 + } + if m.HeartbeatInterval != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.HeartbeatInterval)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xcd + } + if m.ReplicaNetTimeout != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ReplicaNetTimeout)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc0 + } + if len(m.MaxReplicaErrantGtid) > 0 { + i -= len(m.MaxReplicaErrantGtid) + copy(dAtA[i:], m.MaxReplicaErrantGtid) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.MaxReplicaErrantGtid))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xba + } + if len(m.ErrantGtid) > 0 { + i -= len(m.ErrantGtid) + copy(dAtA[i:], m.ErrantGtid) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ErrantGtid))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb2 + } + if m.MaxReplicaGtidMode != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MaxReplicaGtidMode)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa8 + } + if m.MinReplicaGtidMode != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MinReplicaGtidMode)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.GtidMode != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.GtidMode)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + if m.ReplicationStopped { + i-- + if m.ReplicationStopped { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } + if m.LastCheckPartialSuccess { + i-- + if m.LastCheckPartialSuccess { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.LastCheckValid { + i-- + if m.LastCheckValid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } + if m.IsActionableRecovery { + i-- + if m.IsActionableRecovery { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x78 + } + if m.IsDiskStalled { + i-- + if m.IsDiskStalled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x70 + } + if m.IsReadOnly { + i-- + if m.IsReadOnly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x68 + } + if m.IsClusterPrimary { + i-- + if m.IsClusterPrimary { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x60 + } + if m.IsPrimary { + i-- + if m.IsPrimary { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x58 + } + if m.AnalyzedInstanceBinlogCoordinates != nil { + size, err := m.AnalyzedInstanceBinlogCoordinates.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x52 + } + if m.ShardPrimaryTermTimestamp != nil { + size, err := m.ShardPrimaryTermTimestamp.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x4a + } + if m.PrimaryTimestamp != nil { + size, err := m.PrimaryTimestamp.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x42 + } + if m.CurrentTabletType != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CurrentTabletType)) + i-- + dAtA[i] = 0x38 + } + if m.TabletType != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TabletType)) + i-- + dAtA[i] = 0x30 + } + if len(m.AnalyzedShard) > 0 { + i -= len(m.AnalyzedShard) + copy(dAtA[i:], m.AnalyzedShard) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AnalyzedShard))) + i-- + dAtA[i] = 0x2a + } + if len(m.AnalyzedKeyspace) > 0 { + i -= len(m.AnalyzedKeyspace) + copy(dAtA[i:], m.AnalyzedKeyspace) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AnalyzedKeyspace))) + i-- + dAtA[i] = 0x22 + } + if len(m.AnalyzedInstancePrimaryAlias) > 0 { + i -= len(m.AnalyzedInstancePrimaryAlias) + copy(dAtA[i:], m.AnalyzedInstancePrimaryAlias) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AnalyzedInstancePrimaryAlias))) + i-- + dAtA[i] = 0x1a + } + if len(m.AnalyzedInstanceAlias) > 0 { + i -= len(m.AnalyzedInstanceAlias) + copy(dAtA[i:], m.AnalyzedInstanceAlias) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AnalyzedInstanceAlias))) + i-- + dAtA[i] = 0x12 + } + if m.RecoveryId != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RecoveryId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BinlogCoordinates) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.LogFile) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.LogPos != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LogPos)) + } + if m.Type != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Type)) + } + n += len(m.unknownFields) + return n +} + +func (m *ReplicationAnalysis) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RecoveryId != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.RecoveryId)) + } + l = len(m.AnalyzedInstanceAlias) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.AnalyzedInstancePrimaryAlias) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.AnalyzedKeyspace) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.AnalyzedShard) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.TabletType != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.TabletType)) + } + if m.CurrentTabletType != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CurrentTabletType)) + } + if m.PrimaryTimestamp != nil { + l = m.PrimaryTimestamp.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ShardPrimaryTermTimestamp != nil { + l = m.ShardPrimaryTermTimestamp.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.AnalyzedInstanceBinlogCoordinates != nil { + l = m.AnalyzedInstanceBinlogCoordinates.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.IsPrimary { + n += 2 + } + if m.IsClusterPrimary { + n += 2 + } + if m.IsReadOnly { + n += 2 + } + if m.IsDiskStalled { + n += 2 + } + if m.IsActionableRecovery { + n += 2 + } + if m.LastCheckValid { + n += 3 + } + if m.LastCheckPartialSuccess { + n += 3 + } + if m.ReplicationStopped { + n += 3 + } + if m.GtidMode != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.GtidMode)) + } + if m.MinReplicaGtidMode != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.MinReplicaGtidMode)) + } + if m.MaxReplicaGtidMode != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.MaxReplicaGtidMode)) + } + l = len(m.ErrantGtid) + if l > 0 { + n += 2 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.MaxReplicaErrantGtid) + if l > 0 { + n += 2 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ReplicaNetTimeout != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.ReplicaNetTimeout)) + } + if m.HeartbeatInterval != 0 { + n += 6 + } + if m.Analysis != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.Analysis)) + } + l = len(m.Description) + if l > 0 { + n += 2 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.StructureAnalysis) > 0 { + l = 0 + for _, e := range m.StructureAnalysis { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 2 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if m.OracleGtidImmediateTopology { + n += 3 + } + if m.BinlogServerImmediateTopology { + n += 3 + } + if m.SemiSyncPrimaryEnabled { + n += 3 + } + if m.SemiSyncPrimaryStatus { + n += 3 + } + if m.SemiSyncReplicaEnabled { + n += 3 + } + if m.SemiSyncBlocked { + n += 3 + } + if m.CountReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountReplicas)) + } + if m.CountValidReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountValidReplicas)) + } + if m.CountValidReplicatingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountValidReplicatingReplicas)) + } + if m.CountSemiSyncPrimaryWaitForReplica != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountSemiSyncPrimaryWaitForReplica)) + } + if m.CountSemiSyncPrimaryClients != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountSemiSyncPrimaryClients)) + } + if m.CountSemiSyncReplicasEnabled != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountSemiSyncReplicasEnabled)) + } + if m.CountLoggingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountLoggingReplicas)) + } + if m.CountStatementBasedLoggingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountStatementBasedLoggingReplicas)) + } + if m.CountMixedBasedLoggingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountMixedBasedLoggingReplicas)) + } + if m.CountRowBasedLoggingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountRowBasedLoggingReplicas)) + } + if m.CountDistinctMajorVersionsLoggingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountDistinctMajorVersionsLoggingReplicas)) + } + if m.CountDelayedReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountDelayedReplicas)) + } + if m.CountLaggingReplicas != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.CountLaggingReplicas)) + } + n += len(m.unknownFields) + return n +} + +func (m *BinlogCoordinates) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BinlogCoordinates: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BinlogCoordinates: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LogFile", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LogFile = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LogPos", wireType) + } + m.LogPos = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LogPos |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= BinlogType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ReplicationAnalysis) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ReplicationAnalysis: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReplicationAnalysis: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RecoveryId", wireType) + } + m.RecoveryId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RecoveryId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnalyzedInstanceAlias", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AnalyzedInstanceAlias = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnalyzedInstancePrimaryAlias", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AnalyzedInstancePrimaryAlias = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnalyzedKeyspace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AnalyzedKeyspace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnalyzedShard", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AnalyzedShard = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TabletType", wireType) + } + m.TabletType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TabletType |= topodata.TabletType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentTabletType", wireType) + } + m.CurrentTabletType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentTabletType |= topodata.TabletType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrimaryTimestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PrimaryTimestamp == nil { + m.PrimaryTimestamp = &vttime.Time{} + } + if err := m.PrimaryTimestamp.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardPrimaryTermTimestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ShardPrimaryTermTimestamp == nil { + m.ShardPrimaryTermTimestamp = &vttime.Time{} + } + if err := m.ShardPrimaryTermTimestamp.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnalyzedInstanceBinlogCoordinates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AnalyzedInstanceBinlogCoordinates == nil { + m.AnalyzedInstanceBinlogCoordinates = &BinlogCoordinates{} + } + if err := m.AnalyzedInstanceBinlogCoordinates.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPrimary", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPrimary = bool(v != 0) + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsClusterPrimary", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsClusterPrimary = bool(v != 0) + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsReadOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsReadOnly = bool(v != 0) + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsDiskStalled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsDiskStalled = bool(v != 0) + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsActionableRecovery", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsActionableRecovery = bool(v != 0) + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastCheckValid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LastCheckValid = bool(v != 0) + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastCheckPartialSuccess", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LastCheckPartialSuccess = bool(v != 0) + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReplicationStopped", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReplicationStopped = bool(v != 0) + case 19: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GtidMode", wireType) + } + m.GtidMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GtidMode |= GTIDMode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinReplicaGtidMode", wireType) + } + m.MinReplicaGtidMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinReplicaGtidMode |= GTIDMode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 21: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxReplicaGtidMode", wireType) + } + m.MaxReplicaGtidMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxReplicaGtidMode |= GTIDMode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 22: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrantGtid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrantGtid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 23: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxReplicaErrantGtid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaxReplicaErrantGtid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 24: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReplicaNetTimeout", wireType) + } + m.ReplicaNetTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReplicaNetTimeout |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 25: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field HeartbeatInterval", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.HeartbeatInterval = float32(math.Float32frombits(v)) + case 26: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Analysis", wireType) + } + m.Analysis = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Analysis |= AnalysisType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 27: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 28: + if wireType == 0 { + var v StructureAnalysisType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= StructureAnalysisType(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.StructureAnalysis = append(m.StructureAnalysis, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(m.StructureAnalysis) == 0 { + m.StructureAnalysis = make([]StructureAnalysisType, 0, elementCount) + } + for iNdEx < postIndex { + var v StructureAnalysisType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= StructureAnalysisType(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.StructureAnalysis = append(m.StructureAnalysis, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field StructureAnalysis", wireType) + } + case 29: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleGtidImmediateTopology", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OracleGtidImmediateTopology = bool(v != 0) + case 30: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BinlogServerImmediateTopology", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BinlogServerImmediateTopology = bool(v != 0) + case 31: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SemiSyncPrimaryEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SemiSyncPrimaryEnabled = bool(v != 0) + case 32: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SemiSyncPrimaryStatus", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SemiSyncPrimaryStatus = bool(v != 0) + case 33: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SemiSyncReplicaEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SemiSyncReplicaEnabled = bool(v != 0) + case 34: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SemiSyncBlocked", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SemiSyncBlocked = bool(v != 0) + case 35: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountReplicas", wireType) + } + m.CountReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 36: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountValidReplicas", wireType) + } + m.CountValidReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountValidReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 37: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountValidReplicatingReplicas", wireType) + } + m.CountValidReplicatingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountValidReplicatingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 38: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountSemiSyncPrimaryWaitForReplica", wireType) + } + m.CountSemiSyncPrimaryWaitForReplica = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountSemiSyncPrimaryWaitForReplica |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 39: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountSemiSyncPrimaryClients", wireType) + } + m.CountSemiSyncPrimaryClients = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountSemiSyncPrimaryClients |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 40: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountSemiSyncReplicasEnabled", wireType) + } + m.CountSemiSyncReplicasEnabled = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountSemiSyncReplicasEnabled |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 41: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountLoggingReplicas", wireType) + } + m.CountLoggingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountLoggingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 42: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountStatementBasedLoggingReplicas", wireType) + } + m.CountStatementBasedLoggingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountStatementBasedLoggingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 43: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountMixedBasedLoggingReplicas", wireType) + } + m.CountMixedBasedLoggingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountMixedBasedLoggingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 44: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountRowBasedLoggingReplicas", wireType) + } + m.CountRowBasedLoggingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountRowBasedLoggingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 45: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountDistinctMajorVersionsLoggingReplicas", wireType) + } + m.CountDistinctMajorVersionsLoggingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountDistinctMajorVersionsLoggingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 46: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountDelayedReplicas", wireType) + } + m.CountDelayedReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountDelayedReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 47: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountLaggingReplicas", wireType) + } + m.CountLaggingReplicas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CountLaggingReplicas |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/go/vt/vtorc/inst/analysis.go b/go/vt/vtorc/inst/analysis.go index f6948ad89f4..6296b36d0ce 100644 --- a/go/vt/vtorc/inst/analysis.go +++ b/go/vt/vtorc/inst/analysis.go @@ -17,65 +17,10 @@ package inst import ( - "encoding/json" - "time" - - topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/vtorc/config" ) -type AnalysisCode string - -const ( - NoProblem AnalysisCode = "NoProblem" - ClusterHasNoPrimary AnalysisCode = "ClusterHasNoPrimary" - PrimaryTabletDeleted AnalysisCode = "PrimaryTabletDeleted" - InvalidPrimary AnalysisCode = "InvalidPrimary" - InvalidReplica AnalysisCode = "InvalidReplica" - DeadPrimaryWithoutReplicas AnalysisCode = "DeadPrimaryWithoutReplicas" - DeadPrimary AnalysisCode = "DeadPrimary" - DeadPrimaryAndReplicas AnalysisCode = "DeadPrimaryAndReplicas" - DeadPrimaryAndSomeReplicas AnalysisCode = "DeadPrimaryAndSomeReplicas" - PrimaryHasPrimary AnalysisCode = "PrimaryHasPrimary" - PrimaryIsReadOnly AnalysisCode = "PrimaryIsReadOnly" - PrimaryCurrentTypeMismatch AnalysisCode = "PrimaryCurrentTypeMismatch" - PrimarySemiSyncMustBeSet AnalysisCode = "PrimarySemiSyncMustBeSet" - PrimarySemiSyncMustNotBeSet AnalysisCode = "PrimarySemiSyncMustNotBeSet" - ReplicaIsWritable AnalysisCode = "ReplicaIsWritable" - NotConnectedToPrimary AnalysisCode = "NotConnectedToPrimary" - ConnectedToWrongPrimary AnalysisCode = "ConnectedToWrongPrimary" - ReplicationStopped AnalysisCode = "ReplicationStopped" - ReplicaSemiSyncMustBeSet AnalysisCode = "ReplicaSemiSyncMustBeSet" - ReplicaSemiSyncMustNotBeSet AnalysisCode = "ReplicaSemiSyncMustNotBeSet" - ReplicaMisconfigured AnalysisCode = "ReplicaMisconfigured" - UnreachablePrimaryWithLaggingReplicas AnalysisCode = "UnreachablePrimaryWithLaggingReplicas" - UnreachablePrimary AnalysisCode = "UnreachablePrimary" - PrimarySingleReplicaNotReplicating AnalysisCode = "PrimarySingleReplicaNotReplicating" - PrimarySingleReplicaDead AnalysisCode = "PrimarySingleReplicaDead" - AllPrimaryReplicasNotReplicating AnalysisCode = "AllPrimaryReplicasNotReplicating" - AllPrimaryReplicasNotReplicatingOrDead AnalysisCode = "AllPrimaryReplicasNotReplicatingOrDead" - LockedSemiSyncPrimaryHypothesis AnalysisCode = "LockedSemiSyncPrimaryHypothesis" - LockedSemiSyncPrimary AnalysisCode = "LockedSemiSyncPrimary" - PrimarySemiSyncBlocked AnalysisCode = "PrimarySemiSyncBlocked" - ErrantGTIDDetected AnalysisCode = "ErrantGTIDDetected" - PrimaryDiskStalled AnalysisCode = "PrimaryDiskStalled" -) - -type StructureAnalysisCode string - -const ( - StatementAndMixedLoggingReplicasStructureWarning StructureAnalysisCode = "StatementAndMixedLoggingReplicasStructureWarning" - StatementAndRowLoggingReplicasStructureWarning StructureAnalysisCode = "StatementAndRowLoggingReplicasStructureWarning" - MixedAndRowLoggingReplicasStructureWarning StructureAnalysisCode = "MixedAndRowLoggingReplicasStructureWarning" - MultipleMajorVersionsLoggingReplicasStructureWarning StructureAnalysisCode = "MultipleMajorVersionsLoggingReplicasStructureWarning" - NoLoggingReplicasStructureWarning StructureAnalysisCode = "NoLoggingReplicasStructureWarning" - DifferentGTIDModesStructureWarning StructureAnalysisCode = "DifferentGTIDModesStructureWarning" - ErrantGTIDStructureWarning StructureAnalysisCode = "ErrantGTIDStructureWarning" - NoFailoverSupportStructureWarning StructureAnalysisCode = "NoFailoverSupportStructureWarning" - NoWriteablePrimaryStructureWarning StructureAnalysisCode = "NoWriteablePrimaryStructureWarning" - NotEnoughValidSemiSyncReplicasStructureWarning StructureAnalysisCode = "NotEnoughValidSemiSyncReplicasStructureWarning" -) - // PeerAnalysisMap indicates the number of peers agreeing on an analysis. // Key of this map is a InstanceAnalysis.String() type PeerAnalysisMap map[string]int @@ -84,70 +29,32 @@ type ReplicationAnalysisHints struct { AuditAnalysis bool } -// ReplicationAnalysis notes analysis on replication chain status, per instance -type ReplicationAnalysis struct { - AnalyzedInstanceAlias string - AnalyzedInstancePrimaryAlias string - TabletType topodatapb.TabletType - CurrentTabletType topodatapb.TabletType - PrimaryTimeStamp time.Time - ClusterDetails ClusterInfo - AnalyzedKeyspace string - AnalyzedShard string - // ShardPrimaryTermTimestamp is the primary term start time stored in the shard record. - ShardPrimaryTermTimestamp string - AnalyzedInstanceBinlogCoordinates BinlogCoordinates - IsPrimary bool - IsClusterPrimary bool - LastCheckValid bool - LastCheckPartialSuccess bool - CountReplicas uint - CountValidReplicas uint - CountValidReplicatingReplicas uint - ReplicationStopped bool - ErrantGTID string - ReplicaNetTimeout int32 - HeartbeatInterval float64 - Analysis AnalysisCode - Description string - StructureAnalysis []StructureAnalysisCode - OracleGTIDImmediateTopology bool - BinlogServerImmediateTopology bool - SemiSyncPrimaryEnabled bool - SemiSyncPrimaryStatus bool - SemiSyncPrimaryWaitForReplicaCount uint - SemiSyncPrimaryClients uint - SemiSyncReplicaEnabled bool - SemiSyncBlocked bool - CountSemiSyncReplicasEnabled uint - CountLoggingReplicas uint - CountStatementBasedLoggingReplicas uint - CountMixedBasedLoggingReplicas uint - CountRowBasedLoggingReplicas uint - CountDistinctMajorVersionsLoggingReplicas uint - CountDelayedReplicas uint - CountLaggingReplicas uint - IsActionableRecovery bool - RecoveryId int64 - GTIDMode string - MinReplicaGTIDMode string - MaxReplicaGTIDMode string - MaxReplicaGTIDErrant string - IsReadOnly bool - IsDiskStalled bool +// ValidSecondsFromSeenToLastAttemptedCheck returns the maximum allowed elapsed time +// between last_attempted_check to last_checked before we consider the instance as invalid. +func ValidSecondsFromSeenToLastAttemptedCheck() uint { + return config.GetInstancePollSeconds() } -func (replicationAnalysis *ReplicationAnalysis) MarshalJSON() ([]byte, error) { - i := struct { - ReplicationAnalysis - }{} - i.ReplicationAnalysis = *replicationAnalysis +// AnalysisTypeStringToProto converts an analysis type string to a vtorcdatapb.AnalysisType. +func AnalysisTypeStringToProto(analysisType string) vtorcdatapb.AnalysisType { + if i, found := vtorcdatapb.AnalysisType_value[analysisType]; found { + return vtorcdatapb.AnalysisType(i) + } + return vtorcdatapb.AnalysisType_NoProblem +} - return json.Marshal(i) +// AnalysisTypeProtoToString converts an vtorcdatapb.AnalysisType to a string. +func AnalysisTypeProtoToString(analysisType vtorcdatapb.AnalysisType) string { + if str, found := vtorcdatapb.AnalysisType_name[int32(analysisType)]; found { + return str + } + return vtorcdatapb.AnalysisType_name[0] } -// ValidSecondsFromSeenToLastAttemptedCheck returns the maximum allowed elapsed time -// between last_attempted_check to last_checked before we consider the instance as invalid. -func ValidSecondsFromSeenToLastAttemptedCheck() uint { - return config.GetInstancePollSeconds() +// gtidModeToProto converts a gtid_mode string to a vtorcdatapb.GTIDMode. +func gtidModeToProto(gtidMode string) vtorcdatapb.GTIDMode { + if i, found := vtorcdatapb.GTIDMode_value[gtidMode]; found { + return vtorcdatapb.GTIDMode(i) + } + return vtorcdatapb.GTIDMode_OFF } diff --git a/go/vt/vtorc/inst/analysis_dao.go b/go/vt/vtorc/inst/analysis_dao.go index 0e480f74ee8..082d33a268e 100644 --- a/go/vt/vtorc/inst/analysis_dao.go +++ b/go/vt/vtorc/inst/analysis_dao.go @@ -24,10 +24,12 @@ import ( "github.com/patrickmn/go-cache" "google.golang.org/protobuf/encoding/prototext" + "vitess.io/vitess/go/protoutil" "vitess.io/vitess/go/stats" "vitess.io/vitess/go/vt/external/golib/sqlutils" "vitess.io/vitess/go/vt/log" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vtctl/reparentutil/policy" @@ -58,10 +60,10 @@ type clusterAnalysis struct { } // GetReplicationAnalysis will check for replication problems (dead primary; unreachable primary; etc) -func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAnalysisHints) ([]*ReplicationAnalysis, error) { - var result []*ReplicationAnalysis - appendAnalysis := func(analysis *ReplicationAnalysis) { - if analysis.Analysis == NoProblem && len(analysis.StructureAnalysis) == 0 { +func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAnalysisHints) ([]*vtorcdatapb.ReplicationAnalysis, error) { + var result []*vtorcdatapb.ReplicationAnalysis + appendAnalysis := func(analysis *vtorcdatapb.ReplicationAnalysis) { + if analysis.Analysis == vtorcdatapb.AnalysisType_NoProblem && len(analysis.StructureAnalysis) == 0 { return } result = append(result, analysis) @@ -278,8 +280,8 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna clusters := make(map[string]*clusterAnalysis) err := db.Db.QueryVTOrc(query, args, func(m sqlutils.RowMap) error { - a := &ReplicationAnalysis{ - Analysis: NoProblem, + a := &vtorcdatapb.ReplicationAnalysis{ + Analysis: vtorcdatapb.AnalysisType_NoProblem, } tablet := &topodatapb.Tablet{} @@ -306,74 +308,75 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna a.CurrentTabletType = topodatapb.TabletType(m.GetInt("current_tablet_type")) a.AnalyzedKeyspace = m.GetString("keyspace") a.AnalyzedShard = m.GetString("shard") - a.PrimaryTimeStamp = m.GetTime("primary_timestamp") + if primaryTimestamp := m.GetTime("primary_timestamp"); !primaryTimestamp.IsZero() { + a.PrimaryTimestamp = protoutil.TimeToProto(primaryTimestamp) + } if keyspaceType := topodatapb.KeyspaceType(m.GetInt32("keyspace_type")); keyspaceType == topodatapb.KeyspaceType_SNAPSHOT { log.Errorf("keyspace %v is a snapshot keyspace. Skipping.", a.AnalyzedKeyspace) return nil } - a.ShardPrimaryTermTimestamp = m.GetString("shard_primary_term_timestamp") + if termTimestamp := m.GetTime("shard_primary_term_timestamp"); !termTimestamp.IsZero() { + a.ShardPrimaryTermTimestamp = protoutil.TimeToProto(termTimestamp) + } a.IsPrimary = m.GetBool("is_primary") a.AnalyzedInstanceAlias = topoproto.TabletAliasString(tablet.Alias) a.AnalyzedInstancePrimaryAlias = topoproto.TabletAliasString(primaryTablet.Alias) - a.AnalyzedInstanceBinlogCoordinates = BinlogCoordinates{ + a.AnalyzedInstanceBinlogCoordinates = &vtorcdatapb.BinlogCoordinates{ LogFile: m.GetString("binary_log_file"), LogPos: m.GetUint64("binary_log_pos"), - Type: BinaryLog, + Type: vtorcdatapb.BinlogType_BinaryLog, } isStaleBinlogCoordinates := m.GetBool("is_stale_binlog_coordinates") - a.ClusterDetails.Keyspace = m.GetString("keyspace") - a.ClusterDetails.Shard = m.GetString("shard") - a.GTIDMode = m.GetString("gtid_mode") + a.GtidMode = gtidModeToProto(m.GetString("gtid_mode")) a.LastCheckValid = m.GetBool("is_last_check_valid") a.LastCheckPartialSuccess = m.GetBool("last_check_partial_success") - a.CountReplicas = m.GetUint("count_replicas") - a.CountValidReplicas = m.GetUint("count_valid_replicas") - a.CountValidReplicatingReplicas = m.GetUint("count_valid_replicating_replicas") + a.CountReplicas = m.GetUint32("count_replicas") + a.CountValidReplicas = m.GetUint32("count_valid_replicas") + a.CountValidReplicatingReplicas = m.GetUint32("count_valid_replicating_replicas") a.ReplicationStopped = m.GetBool("replication_stopped") - a.ErrantGTID = m.GetString("gtid_errant") + a.ErrantGtid = m.GetString("gtid_errant") - countValidOracleGTIDReplicas := m.GetUint("count_valid_oracle_gtid_replicas") - a.OracleGTIDImmediateTopology = countValidOracleGTIDReplicas == a.CountValidReplicas && a.CountValidReplicas > 0 - countValidBinlogServerReplicas := m.GetUint("count_valid_binlog_server_replicas") + countValidOracleGtidReplicas := m.GetUint32("count_valid_oracle_gtid_replicas") + a.OracleGtidImmediateTopology = countValidOracleGtidReplicas == a.CountValidReplicas && a.CountValidReplicas > 0 + countValidBinlogServerReplicas := m.GetUint32("count_valid_binlog_server_replicas") a.BinlogServerImmediateTopology = countValidBinlogServerReplicas == a.CountValidReplicas && a.CountValidReplicas > 0 a.SemiSyncPrimaryEnabled = m.GetBool("semi_sync_primary_enabled") a.SemiSyncPrimaryStatus = m.GetBool("semi_sync_primary_status") a.SemiSyncBlocked = m.GetBool("semi_sync_blocked") a.SemiSyncReplicaEnabled = m.GetBool("semi_sync_replica_enabled") - a.CountSemiSyncReplicasEnabled = m.GetUint("count_semi_sync_replicas") - // countValidSemiSyncReplicasEnabled := m.GetUint("count_valid_semi_sync_replicas") - a.SemiSyncPrimaryWaitForReplicaCount = m.GetUint("semi_sync_primary_wait_for_replica_count") - a.SemiSyncPrimaryClients = m.GetUint("semi_sync_primary_clients") - - a.MinReplicaGTIDMode = m.GetString("min_replica_gtid_mode") - a.MaxReplicaGTIDMode = m.GetString("max_replica_gtid_mode") - a.MaxReplicaGTIDErrant = m.GetString("max_replica_gtid_errant") - - a.CountLoggingReplicas = m.GetUint("count_logging_replicas") - a.CountStatementBasedLoggingReplicas = m.GetUint("count_statement_based_logging_replicas") - a.CountMixedBasedLoggingReplicas = m.GetUint("count_mixed_based_logging_replicas") - a.CountRowBasedLoggingReplicas = m.GetUint("count_row_based_logging_replicas") - a.CountDistinctMajorVersionsLoggingReplicas = m.GetUint("count_distinct_logging_major_versions") - - a.CountDelayedReplicas = m.GetUint("count_delayed_replicas") - a.CountLaggingReplicas = m.GetUint("count_lagging_replicas") + a.CountSemiSyncReplicasEnabled = m.GetUint32("count_semi_sync_replicas") + a.CountSemiSyncPrimaryWaitForReplica = m.GetUint32("semi_sync_primary_wait_for_replica_count") + a.CountSemiSyncPrimaryClients = m.GetUint32("semi_sync_primary_clients") + + a.MinReplicaGtidMode = gtidModeToProto(m.GetString("min_replica_gtid_mode")) + a.MaxReplicaGtidMode = gtidModeToProto(m.GetString("max_replica_gtid_mode")) + a.MaxReplicaErrantGtid = m.GetString("max_replica_gtid_errant") + + a.CountLoggingReplicas = m.GetUint32("count_logging_replicas") + a.CountStatementBasedLoggingReplicas = m.GetUint32("count_statement_based_logging_replicas") + a.CountMixedBasedLoggingReplicas = m.GetUint32("count_mixed_based_logging_replicas") + a.CountRowBasedLoggingReplicas = m.GetUint32("count_row_based_logging_replicas") + a.CountDistinctMajorVersionsLoggingReplicas = m.GetUint32("count_distinct_logging_major_versions") + + a.CountDelayedReplicas = m.GetUint32("count_delayed_replicas") + a.CountLaggingReplicas = m.GetUint32("count_lagging_replicas") a.ReplicaNetTimeout = m.GetInt32("replica_net_timeout") - a.HeartbeatInterval = m.GetFloat64("heartbeat_interval") + a.HeartbeatInterval = float32(m.GetFloat64("heartbeat_interval")) - a.IsReadOnly = m.GetUint("read_only") == 1 + a.IsReadOnly = m.GetUint32("read_only") == 1 a.IsDiskStalled = m.GetBool("is_disk_stalled") if !a.LastCheckValid { analysisMessage := fmt.Sprintf("analysis: Alias: %+v, Keyspace: %+v, Shard: %+v, IsPrimary: %+v, LastCheckValid: %+v, LastCheckPartialSuccess: %+v, CountReplicas: %+v, CountValidReplicas: %+v, CountValidReplicatingReplicas: %+v, CountLaggingReplicas: %+v, CountDelayedReplicas: %+v", - a.AnalyzedInstanceAlias, a.ClusterDetails.Keyspace, a.ClusterDetails.Shard, a.IsPrimary, a.LastCheckValid, a.LastCheckPartialSuccess, a.CountReplicas, a.CountValidReplicas, a.CountValidReplicatingReplicas, a.CountLaggingReplicas, a.CountDelayedReplicas, + a.AnalyzedInstanceAlias, a.AnalyzedKeyspace, a.AnalyzedShard, a.IsPrimary, a.LastCheckValid, a.LastCheckPartialSuccess, a.CountReplicas, a.CountValidReplicas, a.CountValidReplicatingReplicas, a.CountLaggingReplicas, a.CountDelayedReplicas, ) if util.ClearToLog("analysis_dao", analysisMessage) { log.Infof(analysisMessage) } } - keyspaceShard := getKeyspaceShardName(a.ClusterDetails.Keyspace, a.ClusterDetails.Shard) + keyspaceShard := getKeyspaceShardName(a.AnalyzedKeyspace, a.AnalyzedShard) if clusters[keyspaceShard] == nil { clusters[keyspaceShard] = &clusterAnalysis{} if a.TabletType == topodatapb.TabletType_PRIMARY { @@ -406,141 +409,141 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna } isInvalid := m.GetBool("is_invalid") if a.IsClusterPrimary && isInvalid { - a.Analysis = InvalidPrimary + a.Analysis = vtorcdatapb.AnalysisType_InvalidPrimary a.Description = "VTOrc hasn't been able to reach the primary even once since restart/shutdown" } else if isInvalid { - a.Analysis = InvalidReplica + a.Analysis = vtorcdatapb.AnalysisType_InvalidReplica a.Description = "VTOrc hasn't been able to reach the replica even once since restart/shutdown" } else if a.IsClusterPrimary && !a.LastCheckValid && a.IsDiskStalled { - a.Analysis = PrimaryDiskStalled + a.Analysis = vtorcdatapb.AnalysisType_PrimaryDiskStalled a.Description = "Primary has a stalled disk" ca.hasClusterwideAction = true } else if a.IsClusterPrimary && !a.LastCheckValid && a.CountReplicas == 0 { - a.Analysis = DeadPrimaryWithoutReplicas + a.Analysis = vtorcdatapb.AnalysisType_DeadPrimaryWithoutReplicas a.Description = "Primary cannot be reached by vtorc and has no replica" ca.hasClusterwideAction = true // } else if a.IsClusterPrimary && !a.LastCheckValid && a.CountValidReplicas == a.CountReplicas && a.CountValidReplicatingReplicas == 0 { - a.Analysis = DeadPrimary + a.Analysis = vtorcdatapb.AnalysisType_DeadPrimary a.Description = "Primary cannot be reached by vtorc and none of its replicas is replicating" ca.hasClusterwideAction = true // } else if a.IsClusterPrimary && !a.LastCheckValid && a.CountReplicas > 0 && a.CountValidReplicas == 0 && a.CountValidReplicatingReplicas == 0 { - a.Analysis = DeadPrimaryAndReplicas + a.Analysis = vtorcdatapb.AnalysisType_DeadPrimaryAndReplicas a.Description = "Primary cannot be reached by vtorc and none of its replicas is replicating" ca.hasClusterwideAction = true // } else if a.IsClusterPrimary && !a.LastCheckValid && a.CountValidReplicas < a.CountReplicas && a.CountValidReplicas > 0 && a.CountValidReplicatingReplicas == 0 { - a.Analysis = DeadPrimaryAndSomeReplicas + a.Analysis = vtorcdatapb.AnalysisType_DeadPrimaryAndSomeReplicas a.Description = "Primary cannot be reached by vtorc; some of its replicas are unreachable and none of its reachable replicas is replicating" ca.hasClusterwideAction = true // } else if a.IsClusterPrimary && !a.IsPrimary { - a.Analysis = PrimaryHasPrimary + a.Analysis = vtorcdatapb.AnalysisType_PrimaryHasPrimary a.Description = "Primary is replicating from somewhere else" ca.hasClusterwideAction = true // } else if a.IsClusterPrimary && a.IsReadOnly { - a.Analysis = PrimaryIsReadOnly + a.Analysis = vtorcdatapb.AnalysisType_PrimaryIsReadOnly a.Description = "Primary is read-only" // } else if a.IsClusterPrimary && policy.SemiSyncAckers(ca.durability, tablet) != 0 && !a.SemiSyncPrimaryEnabled { - a.Analysis = PrimarySemiSyncMustBeSet + a.Analysis = vtorcdatapb.AnalysisType_PrimarySemiSyncMustBeSet a.Description = "Primary semi-sync must be set" // } else if a.IsClusterPrimary && policy.SemiSyncAckers(ca.durability, tablet) == 0 && a.SemiSyncPrimaryEnabled { - a.Analysis = PrimarySemiSyncMustNotBeSet + a.Analysis = vtorcdatapb.AnalysisType_PrimarySemiSyncMustNotBeSet a.Description = "Primary semi-sync must not be set" // } else if a.IsClusterPrimary && a.CurrentTabletType != topodatapb.TabletType_UNKNOWN && a.CurrentTabletType != topodatapb.TabletType_PRIMARY { - a.Analysis = PrimaryCurrentTypeMismatch + a.Analysis = vtorcdatapb.AnalysisType_PrimaryCurrentTypeMismatch a.Description = "Primary tablet's current type is not PRIMARY" - } else if topo.IsReplicaType(a.TabletType) && a.ErrantGTID != "" { - a.Analysis = ErrantGTIDDetected + } else if topo.IsReplicaType(a.TabletType) && a.ErrantGtid != "" { + a.Analysis = vtorcdatapb.AnalysisType_ErrantGtidDetected a.Description = "Tablet has errant GTIDs" - } else if topo.IsReplicaType(a.TabletType) && ca.primaryAlias == "" && a.ShardPrimaryTermTimestamp == "" { + } else if topo.IsReplicaType(a.TabletType) && ca.primaryAlias == "" && a.ShardPrimaryTermTimestamp == nil { // ClusterHasNoPrimary should only be detected when the shard record doesn't have any primary term start time specified either. - a.Analysis = ClusterHasNoPrimary + a.Analysis = vtorcdatapb.AnalysisType_ClusterHasNoPrimary a.Description = "Cluster has no primary" ca.hasClusterwideAction = true - } else if topo.IsReplicaType(a.TabletType) && ca.primaryAlias == "" && a.ShardPrimaryTermTimestamp != "" { + } else if topo.IsReplicaType(a.TabletType) && ca.primaryAlias == "" && a.ShardPrimaryTermTimestamp != nil { // If there are no primary tablets, but the shard primary start time isn't empty, then we know // the primary tablet was deleted. - a.Analysis = PrimaryTabletDeleted + a.Analysis = vtorcdatapb.AnalysisType_PrimaryTabletDeleted a.Description = "Primary tablet has been deleted" ca.hasClusterwideAction = true - } else if a.IsPrimary && a.SemiSyncBlocked && a.CountSemiSyncReplicasEnabled >= a.SemiSyncPrimaryWaitForReplicaCount { + } else if a.IsPrimary && a.SemiSyncBlocked && a.CountSemiSyncReplicasEnabled >= a.CountSemiSyncPrimaryWaitForReplica { // The primary is reporting that semi-sync monitor is blocked on writes. // There are enough replicas configured to send semi-sync ACKs such that the primary shouldn't be blocked. // There is some network diruption in progress. We should run an ERS. - a.Analysis = PrimarySemiSyncBlocked + a.Analysis = vtorcdatapb.AnalysisType_PrimarySemiSyncBlocked a.Description = "Writes seem to be blocked on semi-sync acks on the primary, even though sufficient replicas are configured to send ACKs" ca.hasClusterwideAction = true } else if topo.IsReplicaType(a.TabletType) && !a.IsReadOnly { - a.Analysis = ReplicaIsWritable + a.Analysis = vtorcdatapb.AnalysisType_ReplicaIsWritable a.Description = "Replica is writable" // } else if topo.IsReplicaType(a.TabletType) && a.IsPrimary { - a.Analysis = NotConnectedToPrimary + a.Analysis = vtorcdatapb.AnalysisType_NotConnectedToPrimary a.Description = "Not connected to the primary" // - } else if topo.IsReplicaType(a.TabletType) && !a.IsPrimary && math.Round(a.HeartbeatInterval*2) != float64(a.ReplicaNetTimeout) { - a.Analysis = ReplicaMisconfigured + } else if topo.IsReplicaType(a.TabletType) && !a.IsPrimary && math.Round(float64(a.HeartbeatInterval*2)) != float64(a.ReplicaNetTimeout) { + a.Analysis = vtorcdatapb.AnalysisType_ReplicaMisconfigured a.Description = "Replica has been misconfigured" // } else if topo.IsReplicaType(a.TabletType) && !a.IsPrimary && ca.primaryAlias != "" && a.AnalyzedInstancePrimaryAlias != ca.primaryAlias { - a.Analysis = ConnectedToWrongPrimary + a.Analysis = vtorcdatapb.AnalysisType_ConnectedToWrongPrimary a.Description = "Connected to wrong primary" // } else if topo.IsReplicaType(a.TabletType) && !a.IsPrimary && a.ReplicationStopped { - a.Analysis = ReplicationStopped + a.Analysis = vtorcdatapb.AnalysisType_ReplicationStopped a.Description = "Replication is stopped" // } else if topo.IsReplicaType(a.TabletType) && !a.IsPrimary && policy.IsReplicaSemiSync(ca.durability, primaryTablet, tablet) && !a.SemiSyncReplicaEnabled { - a.Analysis = ReplicaSemiSyncMustBeSet + a.Analysis = vtorcdatapb.AnalysisType_ReplicaSemiSyncMustBeSet a.Description = "Replica semi-sync must be set" // } else if topo.IsReplicaType(a.TabletType) && !a.IsPrimary && !policy.IsReplicaSemiSync(ca.durability, primaryTablet, tablet) && a.SemiSyncReplicaEnabled { - a.Analysis = ReplicaSemiSyncMustNotBeSet + a.Analysis = vtorcdatapb.AnalysisType_ReplicaSemiSyncMustNotBeSet a.Description = "Replica semi-sync must not be set" // // TODO(sougou): Events below here are either ignored or not possible. } else if a.IsPrimary && !a.LastCheckValid && a.CountLaggingReplicas == a.CountReplicas && a.CountDelayedReplicas < a.CountReplicas && a.CountValidReplicatingReplicas > 0 { - a.Analysis = UnreachablePrimaryWithLaggingReplicas + a.Analysis = vtorcdatapb.AnalysisType_UnreachablePrimaryWithLaggingReplicas a.Description = "Primary cannot be reached by vtorc and all of its replicas are lagging" // } else if a.IsPrimary && !a.LastCheckValid && !a.LastCheckPartialSuccess && a.CountValidReplicas > 0 && a.CountValidReplicatingReplicas > 0 { // partial success is here to reduce noise - a.Analysis = UnreachablePrimary + a.Analysis = vtorcdatapb.AnalysisType_UnreachablePrimary a.Description = "Primary cannot be reached by vtorc but it has replicating replicas; possibly a network/host issue" // - } else if a.IsPrimary && a.SemiSyncPrimaryEnabled && a.SemiSyncPrimaryStatus && a.SemiSyncPrimaryWaitForReplicaCount > 0 && a.SemiSyncPrimaryClients < a.SemiSyncPrimaryWaitForReplicaCount { + } else if a.IsPrimary && a.SemiSyncPrimaryEnabled && a.SemiSyncPrimaryStatus && a.CountSemiSyncPrimaryWaitForReplica > 0 && a.CountSemiSyncPrimaryClients < a.CountSemiSyncPrimaryWaitForReplica { if isStaleBinlogCoordinates { - a.Analysis = LockedSemiSyncPrimary + a.Analysis = vtorcdatapb.AnalysisType_LockedSemiSyncPrimary a.Description = "Semi sync primary is locked since it doesn't get enough replica acknowledgements" } else { - a.Analysis = LockedSemiSyncPrimaryHypothesis + a.Analysis = vtorcdatapb.AnalysisType_LockedSemiSyncPrimaryHypothesis a.Description = "Semi sync primary seems to be locked, more samplings needed to validate" } // } else if a.IsPrimary && a.LastCheckValid && a.CountReplicas == 1 && a.CountValidReplicas == a.CountReplicas && a.CountValidReplicatingReplicas == 0 { - a.Analysis = PrimarySingleReplicaNotReplicating + a.Analysis = vtorcdatapb.AnalysisType_PrimarySingleReplicaNotReplicating a.Description = "Primary is reachable but its single replica is not replicating" } else if a.IsPrimary && a.LastCheckValid && a.CountReplicas == 1 && a.CountValidReplicas == 0 { - a.Analysis = PrimarySingleReplicaDead + a.Analysis = vtorcdatapb.AnalysisType_PrimarySingleReplicaDead a.Description = "Primary is reachable but its single replica is dead" // } else if a.IsPrimary && a.LastCheckValid && a.CountReplicas > 1 && a.CountValidReplicas == a.CountReplicas && a.CountValidReplicatingReplicas == 0 { - a.Analysis = AllPrimaryReplicasNotReplicating + a.Analysis = vtorcdatapb.AnalysisType_AllPrimaryReplicasNotReplicating a.Description = "Primary is reachable but none of its replicas is replicating" // } else if a.IsPrimary && a.LastCheckValid && a.CountReplicas > 1 && a.CountValidReplicas < a.CountReplicas && a.CountValidReplicas > 0 && a.CountValidReplicatingReplicas == 0 { - a.Analysis = AllPrimaryReplicasNotReplicatingOrDead + a.Analysis = vtorcdatapb.AnalysisType_AllPrimaryReplicasNotReplicatingOrDead a.Description = "Primary is reachable but none of its replicas is replicating" // } // else if a.IsPrimary && a.CountReplicas == 0 { - // a.Analysis = PrimaryWithoutReplicas + // a.Analysis = vtorcdatapb.AnalysisType_PrimaryWithoutReplicas // a.Description = "Primary has no replicas" // } @@ -548,39 +551,39 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna // Moving on to structure analysis // We also do structural checks. See if there's potential danger in promotions if a.IsPrimary && a.CountLoggingReplicas == 0 && a.CountReplicas > 1 { - a.StructureAnalysis = append(a.StructureAnalysis, NoLoggingReplicasStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_NoLoggingReplicasStructureWarning) } if a.IsPrimary && a.CountReplicas > 1 && - !a.OracleGTIDImmediateTopology && + !a.OracleGtidImmediateTopology && !a.BinlogServerImmediateTopology { - a.StructureAnalysis = append(a.StructureAnalysis, NoFailoverSupportStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_NoFailoverSupportStructureWarning) } if a.IsPrimary && a.CountStatementBasedLoggingReplicas > 0 && a.CountMixedBasedLoggingReplicas > 0 { - a.StructureAnalysis = append(a.StructureAnalysis, StatementAndMixedLoggingReplicasStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_StatementAndMixedLoggingReplicasStructureWarning) } if a.IsPrimary && a.CountStatementBasedLoggingReplicas > 0 && a.CountRowBasedLoggingReplicas > 0 { - a.StructureAnalysis = append(a.StructureAnalysis, StatementAndRowLoggingReplicasStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_StatementAndRowLoggingReplicasStructureWarning) } if a.IsPrimary && a.CountMixedBasedLoggingReplicas > 0 && a.CountRowBasedLoggingReplicas > 0 { - a.StructureAnalysis = append(a.StructureAnalysis, MixedAndRowLoggingReplicasStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_MixedAndRowLoggingReplicasStructureWarning) } if a.IsPrimary && a.CountDistinctMajorVersionsLoggingReplicas > 1 { - a.StructureAnalysis = append(a.StructureAnalysis, MultipleMajorVersionsLoggingReplicasStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_MultipleMajorVersionsLoggingReplicasStructureWarning) } - if a.CountReplicas > 0 && (a.GTIDMode != a.MinReplicaGTIDMode || a.GTIDMode != a.MaxReplicaGTIDMode) { - a.StructureAnalysis = append(a.StructureAnalysis, DifferentGTIDModesStructureWarning) + if a.CountReplicas > 0 && (a.GtidMode != a.MinReplicaGtidMode || a.GtidMode != a.MaxReplicaGtidMode) { + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_DifferentGtidModesStructureWarning) } - if a.MaxReplicaGTIDErrant != "" { - a.StructureAnalysis = append(a.StructureAnalysis, ErrantGTIDStructureWarning) + if a.MaxReplicaErrantGtid != "" { + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_ErrantGtidStructureWarning) } if a.IsPrimary && a.IsReadOnly { - a.StructureAnalysis = append(a.StructureAnalysis, NoWriteablePrimaryStructureWarning) + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_NoWriteablePrimaryStructureWarning) } - if a.IsPrimary && a.SemiSyncPrimaryEnabled && !a.SemiSyncPrimaryStatus && a.SemiSyncPrimaryWaitForReplicaCount > 0 && a.SemiSyncPrimaryClients < a.SemiSyncPrimaryWaitForReplicaCount { - a.StructureAnalysis = append(a.StructureAnalysis, NotEnoughValidSemiSyncReplicasStructureWarning) + if a.IsPrimary && a.SemiSyncPrimaryEnabled && !a.SemiSyncPrimaryStatus && a.CountSemiSyncPrimaryWaitForReplica > 0 && a.CountSemiSyncPrimaryClients < a.CountSemiSyncPrimaryWaitForReplica { + a.StructureAnalysis = append(a.StructureAnalysis, vtorcdatapb.StructureAnalysisType_NotEnoughValidSemiSyncReplicasStructureWarning) } } appendAnalysis(a) @@ -604,7 +607,7 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna } // postProcessAnalyses is used to update different analyses based on the information gleaned from looking at all the analyses together instead of individual data. -func postProcessAnalyses(result []*ReplicationAnalysis, clusters map[string]*clusterAnalysis) []*ReplicationAnalysis { +func postProcessAnalyses(result []*vtorcdatapb.ReplicationAnalysis, clusters map[string]*clusterAnalysis) []*vtorcdatapb.ReplicationAnalysis { for { // Store whether we have changed the result of replication analysis or not. resultChanged := false @@ -613,15 +616,15 @@ func postProcessAnalyses(result []*ReplicationAnalysis, clusters map[string]*clu for _, analysis := range result { // If one of them is an InvalidPrimary, then we see if all the other tablets in this keyspace shard are // unable to replicate or not. - if analysis.Analysis == InvalidPrimary { - keyspaceName := analysis.ClusterDetails.Keyspace - shardName := analysis.ClusterDetails.Shard + if analysis.Analysis == vtorcdatapb.AnalysisType_InvalidPrimary { + keyspaceName := analysis.AnalyzedKeyspace + shardName := analysis.AnalyzedShard keyspaceShard := getKeyspaceShardName(keyspaceName, shardName) totalReplicas := clusters[keyspaceShard].totalTablets - 1 var notReplicatingReplicas []int for idx, replicaAnalysis := range result { - if replicaAnalysis.ClusterDetails.Keyspace == keyspaceName && - replicaAnalysis.ClusterDetails.Shard == shardName && topo.IsReplicaType(replicaAnalysis.TabletType) { + if replicaAnalysis.AnalyzedKeyspace == keyspaceName && + replicaAnalysis.AnalyzedShard == shardName && topo.IsReplicaType(replicaAnalysis.TabletType) { // If the replica's last check is invalid or its replication is stopped, then we consider as not replicating. if !replicaAnalysis.LastCheckValid || replicaAnalysis.ReplicationStopped { notReplicatingReplicas = append(notReplicatingReplicas, idx) @@ -632,7 +635,7 @@ func postProcessAnalyses(result []*ReplicationAnalysis, clusters map[string]*clu // In this case, we update the analysis for the primary tablet and remove all the analyses of the replicas. if totalReplicas > 0 && len(notReplicatingReplicas) == totalReplicas { resultChanged = true - analysis.Analysis = DeadPrimary + analysis.Analysis = vtorcdatapb.AnalysisType_DeadPrimary for i := len(notReplicatingReplicas) - 1; i >= 0; i-- { idxToRemove := notReplicatingReplicas[i] result = append(result[0:idxToRemove], result[idxToRemove+1:]...) @@ -651,12 +654,12 @@ func postProcessAnalyses(result []*ReplicationAnalysis, clusters map[string]*clu // auditInstanceAnalysisInChangelog will write down an instance's analysis in the database_instance_analysis_changelog table. // To not repeat recurring analysis code, the database_instance_last_analysis table is used, so that only changes to // analysis codes are written. -func auditInstanceAnalysisInChangelog(tabletAlias string, analysisCode AnalysisCode) error { +func auditInstanceAnalysisInChangelog(tabletAlias string, analysisType vtorcdatapb.AnalysisType) error { if lastWrittenAnalysis, found := recentInstantAnalysis.Get(tabletAlias); found { - if lastWrittenAnalysis == analysisCode { + if lastWrittenAnalysis == analysisType { // Surely nothing new. // And let's expand the timeout - recentInstantAnalysis.Set(tabletAlias, analysisCode, cache.DefaultExpiration) + recentInstantAnalysis.Set(tabletAlias, analysisType, cache.DefaultExpiration) return nil } } @@ -664,6 +667,7 @@ func auditInstanceAnalysisInChangelog(tabletAlias string, analysisCode AnalysisC // Find if the lastAnalysisHasChanged or not while updating the row if it has. lastAnalysisChanged := false { + analysisTypeStr := AnalysisTypeProtoToString(analysisType) sqlResult, err := db.ExecVTOrc(`UPDATE database_instance_last_analysis SET analysis = ?, @@ -672,7 +676,7 @@ func auditInstanceAnalysisInChangelog(tabletAlias string, analysisCode AnalysisC alias = ? AND analysis != ? `, - string(analysisCode), tabletAlias, string(analysisCode), + analysisTypeStr, tabletAlias, analysisTypeStr, ) if err != nil { log.Error(err) @@ -701,7 +705,7 @@ func auditInstanceAnalysisInChangelog(tabletAlias string, analysisCode AnalysisC DATETIME('now'), ? )`, - tabletAlias, string(analysisCode), + tabletAlias, AnalysisTypeProtoToString(analysisType), ) if err != nil { log.Error(err) @@ -714,7 +718,7 @@ func auditInstanceAnalysisInChangelog(tabletAlias string, analysisCode AnalysisC } firstInsertion = rows > 0 } - recentInstantAnalysis.Set(tabletAlias, analysisCode, cache.DefaultExpiration) + recentInstantAnalysis.Set(tabletAlias, analysisType, cache.DefaultExpiration) // If the analysis has changed or if it is the first insertion, we need to make sure we write this change to the database. if !lastAnalysisChanged && !firstInsertion { return nil @@ -730,7 +734,7 @@ func auditInstanceAnalysisInChangelog(tabletAlias string, analysisCode AnalysisC DATETIME('now'), ? )`, - tabletAlias, string(analysisCode), + tabletAlias, AnalysisTypeProtoToString(analysisType), ) if err == nil { analysisChangeWriteCounter.Add(1) diff --git a/go/vt/vtorc/inst/analysis_dao_test.go b/go/vt/vtorc/inst/analysis_dao_test.go index b24e15107d4..3628e435ba9 100644 --- a/go/vt/vtorc/inst/analysis_dao_test.go +++ b/go/vt/vtorc/inst/analysis_dao_test.go @@ -25,6 +25,7 @@ import ( "vitess.io/vitess/go/vt/external/golib/sqlutils" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/vtctl/reparentutil/policy" "vitess.io/vitess/go/vt/vtorc/db" "vitess.io/vitess/go/vt/vtorc/test" @@ -54,7 +55,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { tests := []struct { name string info []*test.InfoForRecoveryAnalysis - codeWanted AnalysisCode + typeWanted vtorcdatapb.AnalysisType shardWanted string keyspaceWanted string wantErr string @@ -76,7 +77,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ClusterHasNoPrimary, + typeWanted: vtorcdatapb.AnalysisType_ClusterHasNoPrimary, }, { name: "PrimaryTabletDeleted", info: []*test.InfoForRecoveryAnalysis{{ @@ -95,7 +96,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimaryTabletDeleted, + typeWanted: vtorcdatapb.AnalysisType_PrimaryTabletDeleted, }, { name: "StalledDiskPrimary", info: []*test.InfoForRecoveryAnalysis{{ @@ -119,7 +120,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimaryDiskStalled, + typeWanted: vtorcdatapb.AnalysisType_PrimaryDiskStalled, }, { name: "PrimarySemiSyncBlocked", info: []*test.InfoForRecoveryAnalysis{{ @@ -148,7 +149,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimarySemiSyncBlocked, + typeWanted: vtorcdatapb.AnalysisType_PrimarySemiSyncBlocked, }, { name: "LockedSemiSync", info: []*test.InfoForRecoveryAnalysis{{ @@ -177,7 +178,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: LockedSemiSyncPrimaryHypothesis, + typeWanted: vtorcdatapb.AnalysisType_LockedSemiSyncPrimaryHypothesis, }, { name: "DeadPrimary", info: []*test.InfoForRecoveryAnalysis{{ @@ -200,7 +201,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: DeadPrimary, + typeWanted: vtorcdatapb.AnalysisType_DeadPrimary, }, { name: "DeadPrimaryWithoutReplicas", info: []*test.InfoForRecoveryAnalysis{{ @@ -221,7 +222,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: DeadPrimaryWithoutReplicas, + typeWanted: vtorcdatapb.AnalysisType_DeadPrimaryWithoutReplicas, }, { name: "DeadPrimaryAndReplicas", info: []*test.InfoForRecoveryAnalysis{{ @@ -242,7 +243,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: DeadPrimaryAndReplicas, + typeWanted: vtorcdatapb.AnalysisType_DeadPrimaryAndReplicas, }, { name: "DeadPrimaryAndSomeReplicas", info: []*test.InfoForRecoveryAnalysis{{ @@ -265,7 +266,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: DeadPrimaryAndSomeReplicas, + typeWanted: vtorcdatapb.AnalysisType_DeadPrimaryAndSomeReplicas, }, { name: "PrimaryHasPrimary", info: []*test.InfoForRecoveryAnalysis{{ @@ -287,7 +288,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimaryHasPrimary, + typeWanted: vtorcdatapb.AnalysisType_PrimaryHasPrimary, }, { name: "PrimaryIsReadOnly", info: []*test.InfoForRecoveryAnalysis{{ @@ -310,7 +311,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimaryIsReadOnly, + typeWanted: vtorcdatapb.AnalysisType_PrimaryIsReadOnly, }, { name: "PrimaryCurrentTypeMismatch", info: []*test.InfoForRecoveryAnalysis{{ @@ -332,7 +333,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimaryCurrentTypeMismatch, + typeWanted: vtorcdatapb.AnalysisType_PrimaryCurrentTypeMismatch, }, { name: "Unknown tablet type shouldn't run the mismatch recovery analysis", info: []*test.InfoForRecoveryAnalysis{{ @@ -357,7 +358,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: NoProblem, + typeWanted: vtorcdatapb.AnalysisType_NoProblem, }, { name: "PrimarySemiSyncMustNotBeSet", info: []*test.InfoForRecoveryAnalysis{{ @@ -380,7 +381,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimarySemiSyncMustNotBeSet, + typeWanted: vtorcdatapb.AnalysisType_PrimarySemiSyncMustNotBeSet, }, { name: "PrimarySemiSyncMustBeSet", info: []*test.InfoForRecoveryAnalysis{{ @@ -403,7 +404,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: PrimarySemiSyncMustBeSet, + typeWanted: vtorcdatapb.AnalysisType_PrimarySemiSyncMustBeSet, }, { name: "NotConnectedToPrimary", info: []*test.InfoForRecoveryAnalysis{{ @@ -441,7 +442,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: NotConnectedToPrimary, + typeWanted: vtorcdatapb.AnalysisType_NotConnectedToPrimary, }, { name: "ReplicaIsWritable", info: []*test.InfoForRecoveryAnalysis{{ @@ -482,7 +483,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ReplicaIsWritable, + typeWanted: vtorcdatapb.AnalysisType_ReplicaIsWritable, }, { name: "ConnectedToWrongPrimary", info: []*test.InfoForRecoveryAnalysis{{ @@ -523,7 +524,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ConnectedToWrongPrimary, + typeWanted: vtorcdatapb.AnalysisType_ConnectedToWrongPrimary, }, { name: "ReplicationStopped", info: []*test.InfoForRecoveryAnalysis{{ @@ -565,7 +566,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ReplicationStopped, + typeWanted: vtorcdatapb.AnalysisType_ReplicationStopped, }, { name: "No recoveries on drained tablets", info: []*test.InfoForRecoveryAnalysis{{ @@ -607,7 +608,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: NoProblem, + typeWanted: vtorcdatapb.AnalysisType_NoProblem, }, { name: "ReplicaMisconfigured", info: []*test.InfoForRecoveryAnalysis{{ @@ -650,7 +651,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ReplicaMisconfigured, + typeWanted: vtorcdatapb.AnalysisType_ReplicaMisconfigured, }, { name: "ReplicaSemiSyncMustBeSet", @@ -694,7 +695,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ReplicaSemiSyncMustBeSet, + typeWanted: vtorcdatapb.AnalysisType_ReplicaSemiSyncMustBeSet, }, { name: "ReplicaSemiSyncMustNotBeSet", info: []*test.InfoForRecoveryAnalysis{{ @@ -736,7 +737,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ReplicaSemiSyncMustNotBeSet, + typeWanted: vtorcdatapb.AnalysisType_ReplicaSemiSyncMustNotBeSet, }, { name: "SnapshotKeyspace", info: []*test.InfoForRecoveryAnalysis{{ @@ -756,7 +757,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: NoProblem, + typeWanted: vtorcdatapb.AnalysisType_NoProblem, }, { name: "EmptyDurabilityPolicy", info: []*test.InfoForRecoveryAnalysis{{ @@ -774,7 +775,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { // We will ignore these keyspaces too until the durability policy is set in the topo server keyspaceWanted: "ks", shardWanted: "0", - codeWanted: NoProblem, + typeWanted: vtorcdatapb.AnalysisType_NoProblem, }, { // If the database_instance table for a tablet is empty (discovery of MySQL information hasn't happened yet or failed) // then we shouldn't run a failure fix on it until the discovery succeeds @@ -814,7 +815,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: InvalidReplica, + typeWanted: vtorcdatapb.AnalysisType_InvalidReplica, }, { name: "DeadPrimary when VTOrc is starting up", info: []*test.InfoForRecoveryAnalysis{{ @@ -856,7 +857,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: DeadPrimary, + typeWanted: vtorcdatapb.AnalysisType_DeadPrimary, }, { name: "Invalid Primary", info: []*test.InfoForRecoveryAnalysis{{ @@ -874,7 +875,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: InvalidPrimary, + typeWanted: vtorcdatapb.AnalysisType_InvalidPrimary, }, { name: "ErrantGTID", info: []*test.InfoForRecoveryAnalysis{{ @@ -916,7 +917,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: ErrantGTIDDetected, + typeWanted: vtorcdatapb.AnalysisType_ErrantGtidDetected, }, { name: "ErrantGTID on a non-replica", info: []*test.InfoForRecoveryAnalysis{{ @@ -958,7 +959,7 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { }}, keyspaceWanted: "ks", shardWanted: "0", - codeWanted: NoProblem, + typeWanted: vtorcdatapb.AnalysisType_NoProblem, }, } for _, tt := range tests { @@ -981,12 +982,12 @@ func TestGetReplicationAnalysisDecision(t *testing.T) { return } require.NoError(t, err) - if tt.codeWanted == NoProblem { + if tt.typeWanted == vtorcdatapb.AnalysisType_NoProblem { require.Len(t, got, 0) return } require.Len(t, got, 1) - require.Equal(t, tt.codeWanted, got[0].Analysis) + require.Equal(t, tt.typeWanted.String(), got[0].Analysis.String()) require.Equal(t, tt.keyspaceWanted, got[0].AnalyzedKeyspace) require.Equal(t, tt.shardWanted, got[0].AnalyzedShard) }) @@ -1002,21 +1003,21 @@ func TestGetReplicationAnalysis(t *testing.T) { tests := []struct { name string sql []string - codeWanted AnalysisCode + typeWanted vtorcdatapb.AnalysisType shardWanted string keyspaceWanted string }{ { name: "No additions", sql: nil, - codeWanted: NoProblem, + typeWanted: vtorcdatapb.AnalysisType_NoProblem, }, { name: "Removing Primary Tablet's Vitess record", sql: []string{ // This query removes the primary tablet's vitess_tablet record `delete from vitess_tablet where port = 6714`, }, - codeWanted: PrimaryTabletDeleted, + typeWanted: vtorcdatapb.AnalysisType_PrimaryTabletDeleted, keyspaceWanted: "ks", shardWanted: "0", }, { @@ -1028,7 +1029,7 @@ func TestGetReplicationAnalysis(t *testing.T) { // As long as we have the vitess record stating that this tablet is the primary // It would be incorrect to run a PRS. // We should still flag this tablet as Invalid. - codeWanted: InvalidPrimary, + typeWanted: vtorcdatapb.AnalysisType_InvalidPrimary, keyspaceWanted: "ks", shardWanted: "0", }, { @@ -1041,7 +1042,7 @@ func TestGetReplicationAnalysis(t *testing.T) { // We should wait for the MySQL information to be refreshed once. // This situation only happens when we haven't been able to read the MySQL information even once for this tablet. // So it is likely a new tablet. - codeWanted: InvalidReplica, + typeWanted: vtorcdatapb.AnalysisType_InvalidReplica, keyspaceWanted: "ks", shardWanted: "0", }, @@ -1061,12 +1062,12 @@ func TestGetReplicationAnalysis(t *testing.T) { got, err := GetReplicationAnalysis("", "", &ReplicationAnalysisHints{}) require.NoError(t, err) - if tt.codeWanted == NoProblem { + if tt.typeWanted == vtorcdatapb.AnalysisType_NoProblem { require.Len(t, got, 0) return } require.Len(t, got, 1) - require.Equal(t, tt.codeWanted, got[0].Analysis) + require.Equal(t, tt.typeWanted, got[0].Analysis) require.Equal(t, tt.keyspaceWanted, got[0].AnalyzedKeyspace) require.Equal(t, tt.shardWanted, got[0].AnalyzedShard) }) @@ -1107,24 +1108,24 @@ func TestAuditInstanceAnalysisInChangelog(t *testing.T) { updates := []struct { tabletAlias string - analysisCode AnalysisCode + analysisType vtorcdatapb.AnalysisType writeCounterExpectation int64 wantErr string }{ { // Store a new analysis for the zone1-100 tablet. tabletAlias: "zone1-100", - analysisCode: ReplicationStopped, + analysisType: vtorcdatapb.AnalysisType_ReplicationStopped, writeCounterExpectation: 1, }, { // Write the same analysis, no new write should happen. tabletAlias: "zone1-100", - analysisCode: ReplicationStopped, + analysisType: vtorcdatapb.AnalysisType_ReplicationStopped, writeCounterExpectation: 1, }, { // Change the analysis. This should trigger an update. tabletAlias: "zone1-100", - analysisCode: ReplicaSemiSyncMustBeSet, + analysisType: vtorcdatapb.AnalysisType_ReplicaSemiSyncMustBeSet, writeCounterExpectation: 2, }, } @@ -1133,7 +1134,7 @@ func TestAuditInstanceAnalysisInChangelog(t *testing.T) { // We sleep 200 milliseconds to make sure that the cache has had time to update. // It should be able to delete entries if the expiration is less than 200 milliseconds. time.Sleep(200 * time.Millisecond) - err := auditInstanceAnalysisInChangelog(upd.tabletAlias, upd.analysisCode) + err := auditInstanceAnalysisInChangelog(upd.tabletAlias, upd.analysisType) if upd.wantErr != "" { require.EqualError(t, err, upd.wantErr) continue @@ -1147,144 +1148,156 @@ func TestAuditInstanceAnalysisInChangelog(t *testing.T) { // TestPostProcessAnalyses tests the functionality of the postProcessAnalyses function. func TestPostProcessAnalyses(t *testing.T) { - ks0 := ClusterInfo{ - Keyspace: "ks", - Shard: "0", - } - ks80 := ClusterInfo{ - Keyspace: "ks", - Shard: "80-", - } + keyspace := "ks" + shard0 := "0" + shard80 := "80-" clusters := map[string]*clusterAnalysis{ - getKeyspaceShardName(ks0.Keyspace, ks0.Shard): { + getKeyspaceShardName(keyspace, shard0): { totalTablets: 4, }, - getKeyspaceShardName(ks80.Keyspace, ks80.Shard): { + getKeyspaceShardName(keyspace, shard80): { totalTablets: 3, }, } tests := []struct { name string - analyses []*ReplicationAnalysis - want []*ReplicationAnalysis + analyses []*vtorcdatapb.ReplicationAnalysis + want []*vtorcdatapb.ReplicationAnalysis }{ { name: "No processing needed", - analyses: []*ReplicationAnalysis{ + analyses: []*vtorcdatapb.ReplicationAnalysis{ { - Analysis: ReplicationStopped, - TabletType: topodatapb.TabletType_REPLICA, - LastCheckValid: true, - ClusterDetails: ks0, + Analysis: vtorcdatapb.AnalysisType_ReplicationStopped, + TabletType: topodatapb.TabletType_REPLICA, + LastCheckValid: true, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, { - Analysis: ReplicaSemiSyncMustBeSet, - LastCheckValid: true, - TabletType: topodatapb.TabletType_REPLICA, - ClusterDetails: ks0, + Analysis: vtorcdatapb.AnalysisType_ReplicaSemiSyncMustBeSet, + LastCheckValid: true, + TabletType: topodatapb.TabletType_REPLICA, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: PrimaryHasPrimary, - LastCheckValid: true, - TabletType: topodatapb.TabletType_REPLICA, - ClusterDetails: ks0, + Analysis: vtorcdatapb.AnalysisType_PrimaryHasPrimary, + LastCheckValid: true, + TabletType: topodatapb.TabletType_REPLICA, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, }, }, { name: "Conversion of InvalidPrimary to DeadPrimary", - analyses: []*ReplicationAnalysis{ + analyses: []*vtorcdatapb.ReplicationAnalysis{ { - Analysis: InvalidPrimary, + Analysis: vtorcdatapb.AnalysisType_InvalidPrimary, AnalyzedInstanceAlias: "zone1-100", TabletType: topodatapb.TabletType_PRIMARY, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-202", TabletType: topodatapb.TabletType_RDONLY, - ClusterDetails: ks80, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, { - Analysis: ConnectedToWrongPrimary, + Analysis: vtorcdatapb.AnalysisType_ConnectedToWrongPrimary, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-101", TabletType: topodatapb.TabletType_REPLICA, ReplicationStopped: true, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: ReplicationStopped, + Analysis: vtorcdatapb.AnalysisType_ReplicationStopped, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-102", TabletType: topodatapb.TabletType_RDONLY, ReplicationStopped: true, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: InvalidReplica, + Analysis: vtorcdatapb.AnalysisType_InvalidReplica, AnalyzedInstanceAlias: "zone1-108", TabletType: topodatapb.TabletType_REPLICA, LastCheckValid: false, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, AnalyzedInstanceAlias: "zone1-302", LastCheckValid: true, TabletType: topodatapb.TabletType_REPLICA, - ClusterDetails: ks80, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, }, - want: []*ReplicationAnalysis{ + want: []*vtorcdatapb.ReplicationAnalysis{ { - Analysis: DeadPrimary, + Analysis: vtorcdatapb.AnalysisType_DeadPrimary, AnalyzedInstanceAlias: "zone1-100", TabletType: topodatapb.TabletType_PRIMARY, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-202", TabletType: topodatapb.TabletType_RDONLY, - ClusterDetails: ks80, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-302", TabletType: topodatapb.TabletType_REPLICA, - ClusterDetails: ks80, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, }, }, { name: "Unable to convert InvalidPrimary to DeadPrimary", - analyses: []*ReplicationAnalysis{ + analyses: []*vtorcdatapb.ReplicationAnalysis{ { - Analysis: InvalidPrimary, + Analysis: vtorcdatapb.AnalysisType_InvalidPrimary, AnalyzedInstanceAlias: "zone1-100", TabletType: topodatapb.TabletType_PRIMARY, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, AnalyzedInstanceAlias: "zone1-202", LastCheckValid: true, TabletType: topodatapb.TabletType_RDONLY, - ClusterDetails: ks80, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-101", TabletType: topodatapb.TabletType_REPLICA, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: ReplicationStopped, + Analysis: vtorcdatapb.AnalysisType_ReplicationStopped, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-102", TabletType: topodatapb.TabletType_RDONLY, ReplicationStopped: true, - ClusterDetails: ks0, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard0, }, { - Analysis: NoProblem, + Analysis: vtorcdatapb.AnalysisType_NoProblem, LastCheckValid: true, AnalyzedInstanceAlias: "zone1-302", TabletType: topodatapb.TabletType_REPLICA, - ClusterDetails: ks80, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard80, }, }, }, diff --git a/go/vt/vtorc/inst/cluster.go b/go/vt/vtorc/inst/cluster.go deleted file mode 100644 index f163885a283..00000000000 --- a/go/vt/vtorc/inst/cluster.go +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2014 Outbrain Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package inst - -// ClusterInfo makes for a cluster status/info summary -type ClusterInfo struct { - Keyspace string - Shard string -} diff --git a/go/vt/vtorc/logic/tablet_discovery_test.go b/go/vt/vtorc/logic/tablet_discovery_test.go index c351fb41c0a..93c2d220f6f 100644 --- a/go/vt/vtorc/logic/tablet_discovery_test.go +++ b/go/vt/vtorc/logic/tablet_discovery_test.go @@ -33,6 +33,7 @@ import ( "vitess.io/vitess/go/vt/external/golib/sqlutils" "vitess.io/vitess/go/vt/key" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/proto/vttime" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/faketopo" @@ -567,22 +568,22 @@ func verifyTabletCount(t *testing.T, countWanted int) { func TestGetLockAction(t *testing.T) { tests := []struct { analysedInstance string - code inst.AnalysisCode + analysisType vtorcdatapb.AnalysisType want string }{ { analysedInstance: "zone1-100", - code: inst.DeadPrimary, + analysisType: vtorcdatapb.AnalysisType_DeadPrimary, want: "VTOrc Recovery for DeadPrimary on zone1-100", }, { analysedInstance: "zone1-200", - code: inst.ReplicationStopped, + analysisType: vtorcdatapb.AnalysisType_ReplicationStopped, want: "VTOrc Recovery for ReplicationStopped on zone1-200", }, } for _, tt := range tests { - t.Run(fmt.Sprintf("%v-%v", tt.analysedInstance, tt.code), func(t *testing.T) { - require.Equal(t, tt.want, getLockAction(tt.analysedInstance, tt.code)) + t.Run(fmt.Sprintf("%v-%v", tt.analysedInstance, tt.analysisType), func(t *testing.T) { + require.Equal(t, tt.want, getLockAction(tt.analysedInstance, tt.analysisType)) }) } } diff --git a/go/vt/vtorc/logic/topology_recovery.go b/go/vt/vtorc/logic/topology_recovery.go index 25b79e1f1bc..046bea67202 100644 --- a/go/vt/vtorc/logic/topology_recovery.go +++ b/go/vt/vtorc/logic/topology_recovery.go @@ -30,6 +30,7 @@ import ( "vitess.io/vitess/go/vt/logutil" logutilpb "vitess.io/vitess/go/vt/proto/logutil" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vtctl/reparentutil" "vitess.io/vitess/go/vt/vtctl/reparentutil/policy" @@ -110,7 +111,7 @@ const ( // TopologyRecovery represents an entry in the topology_recovery table type TopologyRecovery struct { ID int64 - AnalysisEntry inst.ReplicationAnalysis + AnalysisEntry *vtorcdatapb.ReplicationAnalysis SuccessorAlias string IsSuccessful bool AllErrors []string @@ -119,7 +120,7 @@ type TopologyRecovery struct { DetectionID int64 } -func NewTopologyRecovery(replicationAnalysis inst.ReplicationAnalysis) *TopologyRecovery { +func NewTopologyRecovery(replicationAnalysis *vtorcdatapb.ReplicationAnalysis) *TopologyRecovery { topologyRecovery := &TopologyRecovery{} topologyRecovery.AnalysisEntry = replicationAnalysis topologyRecovery.AllErrors = []string{} @@ -165,8 +166,8 @@ func initializeTopologyRecoveryPostConfiguration() { config.WaitForConfigurationToBeLoaded() } -func getLockAction(analysedInstance string, code inst.AnalysisCode) string { - return fmt.Sprintf("VTOrc Recovery for %v on %v", code, analysedInstance) +func getLockAction(analysedInstance string, analysisType vtorcdatapb.AnalysisType) string { + return fmt.Sprintf("VTOrc Recovery for %v on %v", analysisType, analysedInstance) } // LockShard locks the keyspace-shard preventing others from performing conflicting actions. @@ -224,7 +225,7 @@ func resolveRecovery(topologyRecovery *TopologyRecovery, successorInstance *inst } // recoverPrimaryHasPrimary resets the replication on the primary instance -func recoverPrimaryHasPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func recoverPrimaryHasPrimary(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { topologyRecovery, err = AttemptRecoveryRegistration(analysisEntry) if topologyRecovery == nil { message := fmt.Sprintf("found an active or recent recovery on %+v. Will not issue another fixPrimaryHasPrimary.", analysisEntry.AnalyzedInstanceAlias) @@ -253,7 +254,7 @@ func recoverPrimaryHasPrimary(ctx context.Context, analysisEntry *inst.Replicati // runEmergencyReparentOp runs a recovery for which we have to run ERS. Here waitForAllTablets is a boolean telling ERS whether it should wait for all the tablets // or is it okay to skip 1. -func runEmergencyReparentOp(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, recoveryName string, waitForAllTablets bool, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func runEmergencyReparentOp(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, recoveryName string, waitForAllTablets bool, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { // Read the tablet information from the database to find the shard and keyspace of the tablet tablet, err := inst.ReadTablet(analysisEntry.AnalyzedInstanceAlias) if err != nil { @@ -312,16 +313,16 @@ func runEmergencyReparentOp(ctx context.Context, analysisEntry *inst.Replication // recoverDeadPrimary checks a given analysis, decides whether to take action, and possibly takes action // Returns true when action was taken. -func recoverDeadPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func recoverDeadPrimary(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { return runEmergencyReparentOp(ctx, analysisEntry, "RecoverDeadPrimary", false, logger) } // recoverPrimaryTabletDeleted tries to run a recovery for the case where the primary tablet has been deleted. -func recoverPrimaryTabletDeleted(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func recoverPrimaryTabletDeleted(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { return runEmergencyReparentOp(ctx, analysisEntry, "PrimaryTabletDeleted", true, logger) } -func postErsCompletion(topologyRecovery *TopologyRecovery, analysisEntry *inst.ReplicationAnalysis, recoveryName string, promotedReplica *inst.Instance) { +func postErsCompletion(topologyRecovery *TopologyRecovery, analysisEntry *vtorcdatapb.ReplicationAnalysis, recoveryName string, promotedReplica *inst.Instance) { if promotedReplica != nil { message := fmt.Sprintf("promoted replica: %+v", promotedReplica.InstanceAlias) _ = AuditTopologyRecovery(topologyRecovery, message) @@ -331,68 +332,68 @@ func postErsCompletion(topologyRecovery *TopologyRecovery, analysisEntry *inst.R } // checkAndRecoverGenericProblem is a general-purpose recovery function -func checkAndRecoverLockedSemiSyncPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func checkAndRecoverLockedSemiSyncPrimary(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { logger.Warning("No actions in checkAndRecoverLockedSemiSyncPrimary") return false, nil, nil } // checkAndRecoverGenericProblem is a general-purpose recovery function -func checkAndRecoverGenericProblem(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (bool, *TopologyRecovery, error) { +func checkAndRecoverGenericProblem(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (bool, *TopologyRecovery, error) { logger.Warning("No actions in checkAndRecoverGenericProblem") return false, nil, nil } // getCheckAndRecoverFunctionCode gets the recovery function code to use for the given analysis. -func getCheckAndRecoverFunctionCode(analysisCode inst.AnalysisCode, tabletAlias string) recoveryFunction { - switch analysisCode { +func getCheckAndRecoverFunctionCode(analysisType vtorcdatapb.AnalysisType, tabletAlias string) recoveryFunction { + switch analysisType { // primary - case inst.DeadPrimary, inst.DeadPrimaryAndSomeReplicas, inst.PrimaryDiskStalled, inst.PrimarySemiSyncBlocked: + case vtorcdatapb.AnalysisType_DeadPrimary, vtorcdatapb.AnalysisType_DeadPrimaryAndSomeReplicas, vtorcdatapb.AnalysisType_PrimaryDiskStalled, vtorcdatapb.AnalysisType_PrimarySemiSyncBlocked: // If ERS is disabled, we have no way of repairing the cluster. if !config.ERSEnabled() { - log.Infof("VTOrc not configured to run ERS, skipping recovering %v", analysisCode) + log.Infof("VTOrc not configured to run ERS, skipping recovering %v", analysisType) return noRecoveryFunc } return recoverDeadPrimaryFunc - case inst.PrimaryTabletDeleted: + case vtorcdatapb.AnalysisType_PrimaryTabletDeleted: // If ERS is disabled, we have no way of repairing the cluster. if !config.ERSEnabled() { - log.Infof("VTOrc not configured to run ERS, skipping recovering %v", analysisCode) + log.Infof("VTOrc not configured to run ERS, skipping recovering %v", analysisType) return noRecoveryFunc } return recoverPrimaryTabletDeletedFunc - case inst.ErrantGTIDDetected: + case vtorcdatapb.AnalysisType_ErrantGtidDetected: if !config.ConvertTabletWithErrantGTIDs() { - log.Infof("VTOrc not configured to do anything on detecting errant GTIDs, skipping recovering %v", analysisCode) + log.Infof("VTOrc not configured to do anything on detecting errant GTIDs, skipping recovering %v", analysisType) return noRecoveryFunc } return recoverErrantGTIDDetectedFunc - case inst.PrimaryHasPrimary: + case vtorcdatapb.AnalysisType_PrimaryHasPrimary: return recoverPrimaryHasPrimaryFunc - case inst.LockedSemiSyncPrimary: + case vtorcdatapb.AnalysisType_LockedSemiSyncPrimary: return recoverLockedSemiSyncPrimaryFunc - case inst.ClusterHasNoPrimary: + case vtorcdatapb.AnalysisType_ClusterHasNoPrimary: return electNewPrimaryFunc - case inst.PrimaryIsReadOnly, inst.PrimarySemiSyncMustBeSet, inst.PrimarySemiSyncMustNotBeSet, inst.PrimaryCurrentTypeMismatch: + case vtorcdatapb.AnalysisType_PrimaryIsReadOnly, vtorcdatapb.AnalysisType_PrimarySemiSyncMustBeSet, vtorcdatapb.AnalysisType_PrimarySemiSyncMustNotBeSet, vtorcdatapb.AnalysisType_PrimaryCurrentTypeMismatch: return fixPrimaryFunc // replica - case inst.NotConnectedToPrimary, inst.ConnectedToWrongPrimary, inst.ReplicationStopped, inst.ReplicaIsWritable, - inst.ReplicaSemiSyncMustBeSet, inst.ReplicaSemiSyncMustNotBeSet, inst.ReplicaMisconfigured: + case vtorcdatapb.AnalysisType_NotConnectedToPrimary, vtorcdatapb.AnalysisType_ConnectedToWrongPrimary, vtorcdatapb.AnalysisType_ReplicationStopped, vtorcdatapb.AnalysisType_ReplicaIsWritable, + vtorcdatapb.AnalysisType_ReplicaSemiSyncMustBeSet, vtorcdatapb.AnalysisType_ReplicaSemiSyncMustNotBeSet, vtorcdatapb.AnalysisType_ReplicaMisconfigured: return fixReplicaFunc // primary, non actionable - case inst.DeadPrimaryAndReplicas: + case vtorcdatapb.AnalysisType_DeadPrimaryAndReplicas: return recoverGenericProblemFunc - case inst.UnreachablePrimary: + case vtorcdatapb.AnalysisType_UnreachablePrimary: return recoverGenericProblemFunc - case inst.UnreachablePrimaryWithLaggingReplicas: + case vtorcdatapb.AnalysisType_UnreachablePrimaryWithLaggingReplicas: return recoverGenericProblemFunc - case inst.AllPrimaryReplicasNotReplicating: + case vtorcdatapb.AnalysisType_AllPrimaryReplicasNotReplicating: return recoverGenericProblemFunc - case inst.AllPrimaryReplicasNotReplicatingOrDead: + case vtorcdatapb.AnalysisType_AllPrimaryReplicasNotReplicatingOrDead: return recoverGenericProblemFunc } // Right now this is mostly causing noise with no clear action. // Will revisit this in the future. - // case inst.AllPrimaryReplicasStale: + // case vtorcdatapb.AnalysisType_AllPrimaryReplicasStale: // return recoverGenericProblemFunc return noRecoveryFunc @@ -428,7 +429,7 @@ func hasActionableRecovery(recoveryFunctionCode recoveryFunction) bool { // getCheckAndRecoverFunction gets the recovery function for the given code. func getCheckAndRecoverFunction(recoveryFunctionCode recoveryFunction) ( - checkAndRecoverFunction func(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error), + checkAndRecoverFunction func(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error), ) { switch recoveryFunctionCode { case noRecoveryFunc: @@ -496,7 +497,7 @@ func isClusterWideRecovery(recoveryFunctionCode recoveryFunction) bool { } // analysisEntriesHaveSameRecovery tells whether the two analysis entries have the same recovery function or not -func analysisEntriesHaveSameRecovery(prevAnalysis, newAnalysis *inst.ReplicationAnalysis) bool { +func analysisEntriesHaveSameRecovery(prevAnalysis, newAnalysis *vtorcdatapb.ReplicationAnalysis) bool { prevRecoveryFunctionCode := getCheckAndRecoverFunctionCode(prevAnalysis.Analysis, prevAnalysis.AnalyzedInstanceAlias) newRecoveryFunctionCode := getCheckAndRecoverFunctionCode(newAnalysis.Analysis, newAnalysis.AnalyzedInstanceAlias) return prevRecoveryFunctionCode == newRecoveryFunctionCode @@ -504,7 +505,7 @@ func analysisEntriesHaveSameRecovery(prevAnalysis, newAnalysis *inst.Replication // executeCheckAndRecoverFunction will choose the correct check & recovery function based on analysis. // It executes the function synchronously -func executeCheckAndRecoverFunction(analysisEntry *inst.ReplicationAnalysis) (err error) { +func executeCheckAndRecoverFunction(analysisEntry *vtorcdatapb.ReplicationAnalysis) (err error) { countPendingRecoveries.Add(1) defer countPendingRecoveries.Add(-1) @@ -518,7 +519,7 @@ func executeCheckAndRecoverFunction(analysisEntry *inst.ReplicationAnalysis) (er if checkAndRecoverFunctionCode == noRecoveryFunc { logger.Warning("No recovery strategies for problem, aborting recovery") // Unhandled problem type - if analysisEntry.Analysis != inst.NoProblem { + if analysisEntry.Analysis != vtorcdatapb.AnalysisType_NoProblem { if util.ClearToLog("executeCheckAndRecoverFunction", analysisEntry.AnalyzedInstanceAlias) { logger.Warningf("executeCheckAndRecoverFunction: ignoring analysisEntry that has no action plan: tablet: %+v", analysisEntry.AnalyzedInstanceAlias) @@ -688,7 +689,7 @@ func executeCheckAndRecoverFunction(analysisEntry *inst.ReplicationAnalysis) (er // recheckPrimaryHealth check the health of the primary node. // It then checks whether, given the re-discovered primary health, the original recovery is still valid. // If not valid then it will abort the current analysis. -func recheckPrimaryHealth(analysisEntry *inst.ReplicationAnalysis, discoveryFunc func(string, bool)) error { +func recheckPrimaryHealth(analysisEntry *vtorcdatapb.ReplicationAnalysis, discoveryFunc func(string, bool)) error { originalAnalysisEntry := analysisEntry.Analysis primaryTabletAlias := analysisEntry.AnalyzedInstancePrimaryAlias @@ -716,9 +717,9 @@ func recheckPrimaryHealth(analysisEntry *inst.ReplicationAnalysis, discoveryFunc } // checkIfAlreadyFixed checks whether the problem that the analysis entry represents has already been fixed by another agent or not -func checkIfAlreadyFixed(analysisEntry *inst.ReplicationAnalysis) (bool, error) { +func checkIfAlreadyFixed(analysisEntry *vtorcdatapb.ReplicationAnalysis) (bool, error) { // Run a replication analysis again. We will check if the problem persisted - analysisEntries, err := inst.GetReplicationAnalysis(analysisEntry.ClusterDetails.Keyspace, analysisEntry.ClusterDetails.Shard, &inst.ReplicationAnalysisHints{}) + analysisEntries, err := inst.GetReplicationAnalysis(analysisEntry.AnalyzedKeyspace, analysisEntry.AnalyzedShard, &inst.ReplicationAnalysisHints{}) if err != nil { return false, err } @@ -748,7 +749,7 @@ func CheckAndRecover() { // then we reset any counter that is not present in the current analysis. active := make(map[string]struct{}) for _, e := range replicationAnalysis { - if e.Analysis != inst.NoProblem { + if e.Analysis != vtorcdatapb.AnalysisType_NoProblem { names := [...]string{ string(e.Analysis), e.AnalyzedInstanceAlias, @@ -781,7 +782,7 @@ func CheckAndRecover() { } } -func postPrsCompletion(topologyRecovery *TopologyRecovery, analysisEntry *inst.ReplicationAnalysis, promotedReplica *inst.Instance) { +func postPrsCompletion(topologyRecovery *TopologyRecovery, analysisEntry *vtorcdatapb.ReplicationAnalysis, promotedReplica *inst.Instance) { if promotedReplica != nil { message := fmt.Sprintf("promoted replica: %+v", promotedReplica.InstanceAlias) _ = AuditTopologyRecovery(topologyRecovery, message) @@ -791,7 +792,7 @@ func postPrsCompletion(topologyRecovery *TopologyRecovery, analysisEntry *inst.R } // electNewPrimary elects a new primary while none were present before. -func electNewPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func electNewPrimary(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { topologyRecovery, err = AttemptRecoveryRegistration(analysisEntry) if topologyRecovery == nil || err != nil { message := fmt.Sprintf("found an active or recent recovery on %+v. Will not issue another electNewPrimary.", analysisEntry.AnalyzedInstanceAlias) @@ -799,7 +800,7 @@ func electNewPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysi _ = AuditTopologyRecovery(topologyRecovery, message) return false, nil, err } - logger.Infof("Analysis: %v, will elect a new primary for %v:%v", analysisEntry.Analysis, analysisEntry.ClusterDetails.Keyspace, analysisEntry.ClusterDetails.Shard) + logger.Infof("Analysis: %v, will elect a new primary for %v:%v", analysisEntry.Analysis, analysisEntry.AnalyzedKeyspace, analysisEntry.AnalyzedShard) var promotedReplica *inst.Instance // This has to be done in the end; whether successful or not, we should mark that the recovery is done. @@ -843,7 +844,7 @@ func electNewPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysi } // fixPrimary sets the primary as read-write. -func fixPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func fixPrimary(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { topologyRecovery, err = AttemptRecoveryRegistration(analysisEntry) if topologyRecovery == nil { message := fmt.Sprintf("found an active or recent recovery on %+v. Will not issue another fixPrimary.", analysisEntry.AnalyzedInstanceAlias) @@ -877,7 +878,7 @@ func fixPrimary(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, lo } // fixReplica sets the replica as read-only and points it at the current primary. -func fixReplica(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func fixReplica(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { topologyRecovery, err = AttemptRecoveryRegistration(analysisEntry) if topologyRecovery == nil { message := fmt.Sprintf("found an active or recent recovery on %+v. Will not issue another fixReplica.", analysisEntry.AnalyzedInstanceAlias) @@ -921,7 +922,7 @@ func fixReplica(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, lo } // recoverErrantGTIDDetected changes the tablet type of a replica tablet that has errant GTIDs. -func recoverErrantGTIDDetected(ctx context.Context, analysisEntry *inst.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { +func recoverErrantGTIDDetected(ctx context.Context, analysisEntry *vtorcdatapb.ReplicationAnalysis, logger *log.PrefixedLogger) (recoveryAttempted bool, topologyRecovery *TopologyRecovery, err error) { topologyRecovery, err = AttemptRecoveryRegistration(analysisEntry) if topologyRecovery == nil { message := fmt.Sprintf("found an active or recent recovery on %+v. Will not issue another recoverErrantGTIDDetected.", analysisEntry.AnalyzedInstanceAlias) diff --git a/go/vt/vtorc/logic/topology_recovery_dao.go b/go/vt/vtorc/logic/topology_recovery_dao.go index 137251c4fc8..904ff038990 100644 --- a/go/vt/vtorc/logic/topology_recovery_dao.go +++ b/go/vt/vtorc/logic/topology_recovery_dao.go @@ -23,13 +23,14 @@ import ( "vitess.io/vitess/go/vt/external/golib/sqlutils" "vitess.io/vitess/go/vt/log" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/vtorc/config" "vitess.io/vitess/go/vt/vtorc/db" "vitess.io/vitess/go/vt/vtorc/inst" ) // InsertRecoveryDetection inserts the recovery analysis that has been detected. -func InsertRecoveryDetection(analysisEntry *inst.ReplicationAnalysis) error { +func InsertRecoveryDetection(analysisEntry *vtorcdatapb.ReplicationAnalysis) error { sqlResult, err := db.ExecVTOrc(`INSERT OR IGNORE INTO recovery_detection ( alias, @@ -46,8 +47,8 @@ func InsertRecoveryDetection(analysisEntry *inst.ReplicationAnalysis) error { )`, analysisEntry.AnalyzedInstanceAlias, string(analysisEntry.Analysis), - analysisEntry.ClusterDetails.Keyspace, - analysisEntry.ClusterDetails.Shard, + analysisEntry.AnalyzedKeyspace, + analysisEntry.AnalyzedShard, ) if err != nil { log.Error(err) @@ -85,8 +86,8 @@ func writeTopologyRecovery(topologyRecovery *TopologyRecovery) (*TopologyRecover sqlutils.NilIfZero(topologyRecovery.ID), analysisEntry.AnalyzedInstanceAlias, string(analysisEntry.Analysis), - analysisEntry.ClusterDetails.Keyspace, - analysisEntry.ClusterDetails.Shard, + analysisEntry.AnalyzedKeyspace, + analysisEntry.AnalyzedShard, analysisEntry.AnalyzedInstanceAlias, analysisEntry.RecoveryId, ) @@ -109,20 +110,20 @@ func writeTopologyRecovery(topologyRecovery *TopologyRecovery) (*TopologyRecover } // AttemptRecoveryRegistration tries to add a recovery entry; if this fails that means recovery is already in place. -func AttemptRecoveryRegistration(analysisEntry *inst.ReplicationAnalysis) (*TopologyRecovery, error) { +func AttemptRecoveryRegistration(analysisEntry *vtorcdatapb.ReplicationAnalysis) (*TopologyRecovery, error) { // Check if there is an active recovery in progress for the cluster of the given instance. - recoveries, err := ReadActiveClusterRecoveries(analysisEntry.ClusterDetails.Keyspace, analysisEntry.ClusterDetails.Shard) + recoveries, err := ReadActiveClusterRecoveries(analysisEntry.AnalyzedKeyspace, analysisEntry.AnalyzedShard) if err != nil { log.Error(err) return nil, err } if len(recoveries) > 0 { - errMsg := fmt.Sprintf("AttemptRecoveryRegistration: Active recovery (id:%v) in the cluster %s:%s for %s", recoveries[0].ID, analysisEntry.ClusterDetails.Keyspace, analysisEntry.ClusterDetails.Shard, recoveries[0].AnalysisEntry.Analysis) + errMsg := fmt.Sprintf("AttemptRecoveryRegistration: Active recovery (id:%v) in the cluster %s:%s for %s", recoveries[0].ID, analysisEntry.AnalyzedKeyspace, analysisEntry.AnalyzedShard, recoveries[0].AnalysisEntry.Analysis) log.Errorf(errMsg) return nil, errors.New(errMsg) } - topologyRecovery := NewTopologyRecovery(*analysisEntry) + topologyRecovery := NewTopologyRecovery(analysisEntry) topologyRecovery, err = writeTopologyRecovery(topologyRecovery) if err != nil { @@ -180,7 +181,7 @@ func readRecoveries(whereCondition string, limit string, args []any) ([]*Topolog limit, ) err := db.QueryVTOrc(query, args, func(m sqlutils.RowMap) error { - topologyRecovery := *NewTopologyRecovery(inst.ReplicationAnalysis{}) + topologyRecovery := *NewTopologyRecovery(&vtorcdatapb.ReplicationAnalysis{}) topologyRecovery.ID = m.GetInt64("recovery_id") topologyRecovery.RecoveryStartTimestamp = m.GetString("start_recovery") @@ -188,9 +189,9 @@ func readRecoveries(whereCondition string, limit string, args []any) ([]*Topolog topologyRecovery.IsSuccessful = m.GetBool("is_successful") topologyRecovery.AnalysisEntry.AnalyzedInstanceAlias = m.GetString("alias") - topologyRecovery.AnalysisEntry.Analysis = inst.AnalysisCode(m.GetString("analysis")) - topologyRecovery.AnalysisEntry.ClusterDetails.Keyspace = m.GetString("keyspace") - topologyRecovery.AnalysisEntry.ClusterDetails.Shard = m.GetString("shard") + topologyRecovery.AnalysisEntry.Analysis = inst.AnalysisTypeStringToProto(m.GetString("analysis")) + topologyRecovery.AnalysisEntry.AnalyzedKeyspace = m.GetString("keyspace") + topologyRecovery.AnalysisEntry.AnalyzedShard = m.GetString("shard") topologyRecovery.SuccessorAlias = m.GetString("successor_alias") diff --git a/go/vt/vtorc/logic/topology_recovery_dao_test.go b/go/vt/vtorc/logic/topology_recovery_dao_test.go index 6a1d7c4c48f..d05d8053d13 100644 --- a/go/vt/vtorc/logic/topology_recovery_dao_test.go +++ b/go/vt/vtorc/logic/topology_recovery_dao_test.go @@ -23,9 +23,9 @@ import ( "github.com/stretchr/testify/require" "vitess.io/vitess/go/vt/external/golib/sqlutils" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/vtorc/config" "vitess.io/vitess/go/vt/vtorc/db" - "vitess.io/vitess/go/vt/vtorc/inst" ) // TestTopologyRecovery tests various operations related to topology recovery like reading from and writing it to the database. @@ -39,17 +39,13 @@ func TestTopologyRecovery(t *testing.T) { require.NoError(t, err) }() - replicationAnalysis := inst.ReplicationAnalysis{ + replicationAnalysis := &vtorcdatapb.ReplicationAnalysis{ AnalyzedInstanceAlias: "zone1-0000000101", TabletType: tab101.Type, - ClusterDetails: inst.ClusterInfo{ - Keyspace: keyspace, - Shard: shard, - }, - AnalyzedKeyspace: keyspace, - AnalyzedShard: shard, - Analysis: inst.ReplicaIsWritable, - IsReadOnly: false, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard, + Analysis: vtorcdatapb.AnalysisType_ReplicaIsWritable, + IsReadOnly: false, } topologyRecovery := NewTopologyRecovery(replicationAnalysis) @@ -142,13 +138,11 @@ func TestInsertRecoveryDetection(t *testing.T) { defer func() { db.ClearVTOrcDatabase() }() - ra := &inst.ReplicationAnalysis{ + ra := &vtorcdatapb.ReplicationAnalysis{ AnalyzedInstanceAlias: "alias-1", - Analysis: inst.ClusterHasNoPrimary, - ClusterDetails: inst.ClusterInfo{ - Keyspace: keyspace, - Shard: shard, - }, + AnalyzedKeyspace: keyspace, + AnalyzedShard: shard, + Analysis: vtorcdatapb.AnalysisType_ClusterHasNoPrimary, } err := InsertRecoveryDetection(ra) require.NoError(t, err) diff --git a/go/vt/vtorc/logic/topology_recovery_test.go b/go/vt/vtorc/logic/topology_recovery_test.go index 6f967f89051..3e8bac06d82 100644 --- a/go/vt/vtorc/logic/topology_recovery_test.go +++ b/go/vt/vtorc/logic/topology_recovery_test.go @@ -26,6 +26,7 @@ import ( "vitess.io/vitess/go/vt/external/golib/sqlutils" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtorcdatapb "vitess.io/vitess/go/vt/proto/vtorcdata" "vitess.io/vitess/go/vt/topo/memorytopo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vtctl/reparentutil/policy" @@ -38,77 +39,80 @@ import ( func TestAnalysisEntriesHaveSameRecovery(t *testing.T) { tests := []struct { - prevAnalysisCode inst.AnalysisCode - newAnalysisCode inst.AnalysisCode + prevAnalysisCode vtorcdatapb.AnalysisType + newAnalysisCode vtorcdatapb.AnalysisType shouldBeEqual bool }{ { // DeadPrimary and DeadPrimaryAndSomeReplicas have the same recovery - prevAnalysisCode: inst.DeadPrimary, - newAnalysisCode: inst.DeadPrimaryAndSomeReplicas, + prevAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimaryAndSomeReplicas, shouldBeEqual: true, }, { // DeadPrimary and StalledDiskPrimary have the same recovery - prevAnalysisCode: inst.DeadPrimary, - newAnalysisCode: inst.PrimaryDiskStalled, + prevAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimaryDiskStalled, shouldBeEqual: true, }, { // PrimarySemiSyncBlocked and PrimaryDiskStalled have the same recovery - prevAnalysisCode: inst.PrimarySemiSyncBlocked, - newAnalysisCode: inst.PrimaryDiskStalled, + prevAnalysisCode: vtorcdatapb.AnalysisType_PrimarySemiSyncBlocked, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimaryDiskStalled, shouldBeEqual: true, }, { // DeadPrimary and PrimaryTabletDeleted are different recoveries. - prevAnalysisCode: inst.DeadPrimary, - newAnalysisCode: inst.PrimaryTabletDeleted, + prevAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimaryTabletDeleted, shouldBeEqual: false, }, { // same codes will always have same recovery - prevAnalysisCode: inst.DeadPrimary, - newAnalysisCode: inst.DeadPrimary, + prevAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, shouldBeEqual: true, }, { - prevAnalysisCode: inst.PrimaryHasPrimary, - newAnalysisCode: inst.DeadPrimaryAndSomeReplicas, + prevAnalysisCode: vtorcdatapb.AnalysisType_PrimaryHasPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimaryAndSomeReplicas, shouldBeEqual: false, }, { - prevAnalysisCode: inst.DeadPrimary, - newAnalysisCode: inst.PrimaryHasPrimary, + prevAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimaryHasPrimary, shouldBeEqual: false, }, { - prevAnalysisCode: inst.LockedSemiSyncPrimary, - newAnalysisCode: inst.PrimaryHasPrimary, + prevAnalysisCode: vtorcdatapb.AnalysisType_LockedSemiSyncPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimaryHasPrimary, shouldBeEqual: false, }, { - prevAnalysisCode: inst.PrimaryIsReadOnly, - newAnalysisCode: inst.PrimarySemiSyncMustNotBeSet, + prevAnalysisCode: vtorcdatapb.AnalysisType_PrimaryIsReadOnly, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimarySemiSyncMustNotBeSet, shouldBeEqual: true, }, { - prevAnalysisCode: inst.PrimarySemiSyncMustBeSet, - newAnalysisCode: inst.PrimarySemiSyncMustNotBeSet, + prevAnalysisCode: vtorcdatapb.AnalysisType_PrimarySemiSyncMustBeSet, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimarySemiSyncMustNotBeSet, shouldBeEqual: true, }, { - prevAnalysisCode: inst.PrimaryCurrentTypeMismatch, - newAnalysisCode: inst.PrimarySemiSyncMustNotBeSet, + prevAnalysisCode: vtorcdatapb.AnalysisType_PrimaryCurrentTypeMismatch, + newAnalysisCode: vtorcdatapb.AnalysisType_PrimarySemiSyncMustNotBeSet, shouldBeEqual: true, }, { - prevAnalysisCode: inst.PrimaryIsReadOnly, - newAnalysisCode: inst.DeadPrimary, + prevAnalysisCode: vtorcdatapb.AnalysisType_PrimaryIsReadOnly, + newAnalysisCode: vtorcdatapb.AnalysisType_DeadPrimary, shouldBeEqual: false, }, { - prevAnalysisCode: inst.NotConnectedToPrimary, - newAnalysisCode: inst.ConnectedToWrongPrimary, + prevAnalysisCode: vtorcdatapb.AnalysisType_NotConnectedToPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_ConnectedToWrongPrimary, shouldBeEqual: true, }, { - prevAnalysisCode: inst.ConnectedToWrongPrimary, - newAnalysisCode: inst.ReplicaIsWritable, + prevAnalysisCode: vtorcdatapb.AnalysisType_ConnectedToWrongPrimary, + newAnalysisCode: vtorcdatapb.AnalysisType_ReplicaIsWritable, shouldBeEqual: true, }, } t.Parallel() for _, tt := range tests { t.Run(string(tt.prevAnalysisCode)+","+string(tt.newAnalysisCode), func(t *testing.T) { - res := analysisEntriesHaveSameRecovery(&inst.ReplicationAnalysis{Analysis: tt.prevAnalysisCode}, &inst.ReplicationAnalysis{Analysis: tt.newAnalysisCode}) + res := analysisEntriesHaveSameRecovery( + &vtorcdatapb.ReplicationAnalysis{Analysis: tt.prevAnalysisCode}, + &vtorcdatapb.ReplicationAnalysis{Analysis: tt.newAnalysisCode}, + ) require.Equal(t, tt.shouldBeEqual, res) }) } @@ -138,7 +142,7 @@ func TestElectNewPrimaryPanic(t *testing.T) { } err = inst.SaveTablet(tablet) require.NoError(t, err) - analysisEntry := &inst.ReplicationAnalysis{ + analysisEntry := &vtorcdatapb.ReplicationAnalysis{ AnalyzedInstanceAlias: topoproto.TabletAliasString(tablet.Alias), } ctx, cancel := context.WithCancel(context.Background()) @@ -188,13 +192,13 @@ func TestRecoveryRegistration(t *testing.T) { require.NoError(t, err) err = inst.SaveTablet(replica) require.NoError(t, err) - primaryAnalysisEntry := inst.ReplicationAnalysis{ + primaryAnalysisEntry := vtorcdatapb.ReplicationAnalysis{ AnalyzedInstanceAlias: topoproto.TabletAliasString(primary.Alias), - Analysis: inst.ReplicationStopped, + Analysis: vtorcdatapb.AnalysisType_ReplicationStopped, } - replicaAnalysisEntry := inst.ReplicationAnalysis{ + replicaAnalysisEntry := vtorcdatapb.ReplicationAnalysis{ AnalyzedInstanceAlias: topoproto.TabletAliasString(replica.Alias), - Analysis: inst.DeadPrimary, + Analysis: vtorcdatapb.AnalysisType_DeadPrimary, } ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -221,80 +225,80 @@ func TestGetCheckAndRecoverFunctionCode(t *testing.T) { name string ersEnabled bool convertTabletWithErrantGTIDs bool - analysisCode inst.AnalysisCode + analysisType vtorcdatapb.AnalysisType wantRecoveryFunction recoveryFunction }{ { name: "DeadPrimary with ERS enabled", ersEnabled: true, - analysisCode: inst.DeadPrimary, + analysisType: vtorcdatapb.AnalysisType_DeadPrimary, wantRecoveryFunction: recoverDeadPrimaryFunc, }, { name: "DeadPrimary with ERS disabled", ersEnabled: false, - analysisCode: inst.DeadPrimary, + analysisType: vtorcdatapb.AnalysisType_DeadPrimary, wantRecoveryFunction: noRecoveryFunc, }, { name: "StalledDiskPrimary with ERS enabled", ersEnabled: true, - analysisCode: inst.PrimaryDiskStalled, + analysisType: vtorcdatapb.AnalysisType_PrimaryDiskStalled, wantRecoveryFunction: recoverDeadPrimaryFunc, }, { name: "StalledDiskPrimary with ERS disabled", ersEnabled: false, - analysisCode: inst.PrimaryDiskStalled, + analysisType: vtorcdatapb.AnalysisType_PrimaryDiskStalled, wantRecoveryFunction: noRecoveryFunc, }, { name: "PrimarySemiSyncBlocked with ERS enabled", ersEnabled: true, - analysisCode: inst.PrimarySemiSyncBlocked, + analysisType: vtorcdatapb.AnalysisType_PrimarySemiSyncBlocked, wantRecoveryFunction: recoverDeadPrimaryFunc, }, { name: "PrimarySemiSyncBlocked with ERS disabled", ersEnabled: false, - analysisCode: inst.PrimarySemiSyncBlocked, + analysisType: vtorcdatapb.AnalysisType_PrimarySemiSyncBlocked, wantRecoveryFunction: noRecoveryFunc, }, { name: "PrimaryTabletDeleted with ERS enabled", ersEnabled: true, - analysisCode: inst.PrimaryTabletDeleted, + analysisType: vtorcdatapb.AnalysisType_PrimaryTabletDeleted, wantRecoveryFunction: recoverPrimaryTabletDeletedFunc, }, { name: "PrimaryTabletDeleted with ERS disabled", ersEnabled: false, - analysisCode: inst.PrimaryTabletDeleted, + analysisType: vtorcdatapb.AnalysisType_PrimaryTabletDeleted, wantRecoveryFunction: noRecoveryFunc, }, { name: "PrimaryHasPrimary", ersEnabled: false, - analysisCode: inst.PrimaryHasPrimary, + analysisType: vtorcdatapb.AnalysisType_PrimaryHasPrimary, wantRecoveryFunction: recoverPrimaryHasPrimaryFunc, }, { name: "ClusterHasNoPrimary", ersEnabled: false, - analysisCode: inst.ClusterHasNoPrimary, + analysisType: vtorcdatapb.AnalysisType_ClusterHasNoPrimary, wantRecoveryFunction: electNewPrimaryFunc, }, { name: "ReplicationStopped", ersEnabled: false, - analysisCode: inst.ReplicationStopped, + analysisType: vtorcdatapb.AnalysisType_ReplicationStopped, wantRecoveryFunction: fixReplicaFunc, }, { name: "PrimarySemiSyncMustBeSet", ersEnabled: false, - analysisCode: inst.PrimarySemiSyncMustBeSet, + analysisType: vtorcdatapb.AnalysisType_PrimarySemiSyncMustBeSet, wantRecoveryFunction: fixPrimaryFunc, }, { name: "ErrantGTIDDetected", ersEnabled: false, convertTabletWithErrantGTIDs: true, - analysisCode: inst.ErrantGTIDDetected, + analysisType: vtorcdatapb.AnalysisType_ErrantGtidDetected, wantRecoveryFunction: recoverErrantGTIDDetectedFunc, }, { name: "ErrantGTIDDetected with --change-tablets-with-errant-gtid-to-drained false", ersEnabled: false, convertTabletWithErrantGTIDs: false, - analysisCode: inst.ErrantGTIDDetected, + analysisType: vtorcdatapb.AnalysisType_ErrantGtidDetected, wantRecoveryFunction: noRecoveryFunc, }, } @@ -309,7 +313,7 @@ func TestGetCheckAndRecoverFunctionCode(t *testing.T) { config.SetConvertTabletWithErrantGTIDs(tt.convertTabletWithErrantGTIDs) defer config.SetConvertTabletWithErrantGTIDs(convertErrantVal) - gotFunc := getCheckAndRecoverFunctionCode(tt.analysisCode, "") + gotFunc := getCheckAndRecoverFunctionCode(tt.analysisType, "") require.EqualValues(t, tt.wantRecoveryFunction, gotFunc) }) } @@ -400,9 +404,9 @@ func TestRecheckPrimaryHealth(t *testing.T) { // set replication analysis in Vtorc DB. db.Db = test.NewTestDB([][]sqlutils.RowMap{rowMaps}) - err := recheckPrimaryHealth(&inst.ReplicationAnalysis{ + err := recheckPrimaryHealth(&vtorcdatapb.ReplicationAnalysis{ AnalyzedInstanceAlias: "zon1-0000000100", - Analysis: inst.ReplicationStopped, + Analysis: vtorcdatapb.AnalysisType_ReplicationStopped, AnalyzedKeyspace: "ks", AnalyzedShard: "0", }, func(s string, b bool) { diff --git a/proto/vtorcdata.proto b/proto/vtorcdata.proto new file mode 100644 index 00000000000..0bd42b2e661 --- /dev/null +++ b/proto/vtorcdata.proto @@ -0,0 +1,142 @@ +/* +Copyright 2025 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file defines the replication related structures we use. + +syntax = "proto3"; +option go_package = "vitess.io/vitess/go/vt/proto/vtorcdata"; + +package vtorcdata; + +import "topodata.proto"; +import "vttime.proto"; + +enum AnalysisType { + NoProblem = 0; + ClusterHasNoPrimary = 1; + PrimaryTabletDeleted = 2; + InvalidPrimary = 3; + InvalidReplica = 4; + DeadPrimaryWithoutReplicas = 5; + DeadPrimary = 6; + DeadPrimaryAndReplicas = 7; + DeadPrimaryAndSomeReplicas = 8; + PrimaryHasPrimary = 9; + PrimaryIsReadOnly = 10; + PrimaryCurrentTypeMismatch = 11; + PrimarySemiSyncMustBeSet = 12; + PrimarySemiSyncMustNotBeSet = 13; + ReplicaIsWritable = 14; + NotConnectedToPrimary = 15; + ConnectedToWrongPrimary = 16; + ReplicationStopped = 17; + ReplicaSemiSyncMustBeSet = 18; + ReplicaSemiSyncMustNotBeSet = 19; + ReplicaMisconfigured = 20; + UnreachablePrimaryWithLaggingReplicas = 21; + UnreachablePrimary = 22; + PrimarySingleReplicaNotReplicating = 23; + PrimarySingleReplicaDead = 24; + AllPrimaryReplicasNotReplicating = 25; + AllPrimaryReplicasNotReplicatingOrDead = 26; + LockedSemiSyncPrimaryHypothesis = 27; + LockedSemiSyncPrimary = 28; + PrimarySemiSyncBlocked = 29; + ErrantGtidDetected = 30; + PrimaryDiskStalled = 31; +} + +enum StructureAnalysisType { + NoStructureAnalysis = 0; + StatementAndMixedLoggingReplicasStructureWarning = 1; + StatementAndRowLoggingReplicasStructureWarning = 2; + MixedAndRowLoggingReplicasStructureWarning = 3; + MultipleMajorVersionsLoggingReplicasStructureWarning = 4; + NoLoggingReplicasStructureWarning = 5; + DifferentGtidModesStructureWarning = 6; + ErrantGtidStructureWarning = 7; + NoFailoverSupportStructureWarning = 8; + NoWriteablePrimaryStructureWarning = 9; + NotEnoughValidSemiSyncReplicasStructureWarning = 10; +} + +enum GTIDMode { + OFF = 0; + OFF_PERMISSIVE = 1; + ON_PERMISSIVE = 2; + ON = 3; +} + +enum BinlogType { + BinaryLog = 0; + RelayLog = 1; +} + +message BinlogCoordinates { + string LogFile = 1; + uint64 LogPos = 2; + BinlogType type = 3; +} + +message ReplicationAnalysis { + int64 recovery_id = 1; + string analyzed_instance_alias = 2; + string analyzed_instance_primary_alias = 3; + string analyzed_keyspace = 4; + string analyzed_shard = 5; + topodata.TabletType tablet_type = 6; + topodata.TabletType current_tablet_type = 7; + vttime.Time primary_timestamp = 8; + vttime.Time shard_primary_term_timestamp = 9; + BinlogCoordinates analyzed_instance_binlog_coordinates = 10; + bool is_primary = 11; + bool is_cluster_primary = 12; + bool is_read_only = 13; + bool is_disk_stalled = 14; + bool is_actionable_recovery = 15; + bool last_check_valid = 16; + bool last_check_partial_success = 17; + bool replication_stopped = 18; + GTIDMode gtid_mode = 19; + GTIDMode min_replica_gtid_mode = 20; + GTIDMode max_replica_gtid_mode = 21; + string errant_gtid = 22; + string max_replica_errant_gtid = 23; + int32 replica_net_timeout = 24; + float heartbeat_interval = 25; + AnalysisType analysis = 26; + string description = 27; + repeated StructureAnalysisType structure_analysis = 28; + bool oracle_gtid_immediate_topology = 29; + bool binlog_server_immediate_topology = 30; + bool semi_sync_primary_enabled = 31; + bool semi_sync_primary_status = 32; + bool semi_sync_replica_enabled = 33; + bool semi_sync_blocked = 34; + uint32 count_replicas = 35; + uint32 count_valid_replicas = 36; + uint32 count_valid_replicating_replicas = 37; + uint32 count_semi_sync_primary_wait_for_replica = 38; + uint32 count_semi_sync_primary_clients = 39; + uint32 count_semi_sync_replicas_enabled = 40; + uint32 count_logging_replicas = 41; + uint32 count_statement_based_logging_replicas = 42; + uint32 count_mixed_based_logging_replicas = 43; + uint32 count_row_based_logging_replicas = 44; + uint32 count_distinct_major_versions_logging_replicas = 45; + uint32 count_delayed_replicas = 46; + uint32 count_lagging_replicas = 47; +}