Skip to content

Commit

Permalink
FindErrantGTIDs: superset is not an errant GTID situation (#16725)
Browse files Browse the repository at this point in the history
Signed-off-by: deepthi <deepthi@planetscale.com>
  • Loading branch information
deepthi authored Sep 6, 2024
1 parent c852274 commit 5d562c7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
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

0 comments on commit 5d562c7

Please sign in to comment.