Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-18.0] FindErrantGTIDs: superset is not an errant GTID situation (#16725) #16727

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions go/mysql/replication/replication_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ func (s *ReplicationStatus) FindErrantGTIDs(otherReplicaStatuses []*ReplicationS
otherSets = append(otherSets, otherSet)
}

if len(otherSets) == 1 {
// If there is only one replica to compare against, and one is a subset of the other, then we consider them not to be errant.
// It simply means that one replica might be behind on replication.
if relayLogSet.Contains(otherSets[0]) || otherSets[0].Contains(relayLogSet) {
return nil, nil
}
}

// Copy set for final diffSet so we don't mutate receiver.
diffSet := make(Mysql56GTIDSet, len(relayLogSet))
for sid, intervals := range relayLogSet {
Expand Down
10 changes: 10 additions & 0 deletions go/mysql/replication/replication_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ func TestFindErrantGTIDs(t *testing.T) {
otherRepStatuses: []*ReplicationStatus{{SourceUUID: sid1, RelayLogPosition: Position{GTIDSet: set1}}},
// servers with the same GTID sets should not be diagnosed with errant GTIDs
want: nil,
}, {
mainRepStatus: &ReplicationStatus{SourceUUID: sourceSID, RelayLogPosition: Position{GTIDSet: set2}},
otherRepStatuses: []*ReplicationStatus{{SourceUUID: sid1, RelayLogPosition: Position{GTIDSet: set3}}},
// set2 is a strict subset of set3
want: nil,
}, {
mainRepStatus: &ReplicationStatus{SourceUUID: sourceSID, RelayLogPosition: Position{GTIDSet: set3}},
otherRepStatuses: []*ReplicationStatus{{SourceUUID: sid1, RelayLogPosition: Position{GTIDSet: set2}}},
// set3 is a strict superset of set2
want: nil,
}}

for _, testcase := range testcases {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtctl/reparentutil/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func FindValidEmergencyReparentCandidates(
case len(errantGTIDs) != 0:
// This tablet has errant GTIDs. It's not a valid candidate for
// reparent, so don't insert it into the final mapping.
log.Errorf("skipping %v because we detected errant GTIDs - %v", alias, errantGTIDs)
log.Errorf("skipping %v with GTIDSet:%v because we detected errant GTIDs - %v", alias, relayLogGTIDSet, errantGTIDs)
continue
}

Expand Down
26 changes: 20 additions & 6 deletions go/vt/vtctl/reparentutil/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,41 @@ func TestFindValidEmergencyReparentCandidates(t *testing.T) {
shouldErr: false,
},
{
name: "tablet with errant GTIDs is excluded",
name: "tablet with superset GTIDs is included",
statusMap: map[string]*replicationdatapb.StopReplicationStatus{
"r1": {
After: &replicationdatapb.Status{
SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562",
RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5",
},
},
"errant": {
"r2": {
After: &replicationdatapb.Status{
SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562",
RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5,AAAAAAAA-71CA-11E1-9E33-C80AA9429562:1",
},
},
},
primaryStatusMap: map[string]*replicationdatapb.PrimaryStatus{
"p1": {
Position: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5",
expected: []string{"r1", "r2"},
shouldErr: false,
},
{
name: "tablets with errant GTIDs are excluded",
statusMap: map[string]*replicationdatapb.StopReplicationStatus{
"r1": {
After: &replicationdatapb.Status{
SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562",
RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5,AAAAAAAA-71CA-11E1-9E33-C80AA9429562:1",
},
},
"r2": {
After: &replicationdatapb.Status{
SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562",
RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5,AAAAAAAA-71CA-11E1-9E33-C80AA9429562:2-3",
},
},
},
expected: []string{"r1", "p1"},
expected: []string{},
shouldErr: false,
},
{
Expand Down
Loading