Skip to content
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
5 changes: 5 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ func (s *VtctldServer) BackupShard(req *vtctldatapb.BackupShardRequest, stream v
continue
}

// ignore tablet with an unknown replication lag status
if stats[i].ReplicationLagUnknown {
continue
}

if lag := stats[i].ReplicationLagSeconds; backupTablet == nil || lag < backupTabletLag {
backupTablet = tablet.Tablet
backupTabletLag = lag
Expand Down
22 changes: 22 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ func TestBackupShard(t *testing.T) {
"zone1-0000000100": {
Events: []*logutilpb.Event{{}, {}, {}},
},
"zone1-0000000101": {
Events: []*logutilpb.Event{{}, {}, {}},
},
},
PrimaryPositionResults: map[string]struct {
Position string
Expand All @@ -951,11 +954,18 @@ func TestBackupShard(t *testing.T) {
"zone1-0000000100": {
Position: &replicationdatapb.Status{
ReplicationLagSeconds: 0,
ReplicationLagUnknown: true,
},
},
"zone1-0000000101": {
Position: &replicationdatapb.Status{
ReplicationLagSeconds: 1,
},
},
},
SetReplicationSourceResults: map[string]error{
"zone1-0000000100": nil,
"zone1-0000000101": nil,
},
},
tablets: []*topodatapb.Tablet{
Expand All @@ -968,6 +978,15 @@ func TestBackupShard(t *testing.T) {
Shard: "-",
Type: topodatapb.TabletType_REPLICA,
},
{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 101,
},
Keyspace: "ks",
Shard: "-",
Type: topodatapb.TabletType_REPLICA,
},
{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Expand All @@ -985,6 +1004,9 @@ func TestBackupShard(t *testing.T) {
assertion: func(t *testing.T, responses []*vtctldatapb.BackupResponse, err error) {
assert.ErrorIs(t, err, io.EOF, "expected Recv loop to end with io.EOF")
assert.Equal(t, 3, len(responses), "expected 3 messages from backupclient stream")
for _, resp := range responses {
assert.Equal(t, 101, int(resp.TabletAlias.Uid))
}
},
},
{
Expand Down
Loading