From ddad61a8839920dcbc0d2c2236b73111ebef6ccd Mon Sep 17 00:00:00 2001 From: Jun Wang Date: Tue, 28 Nov 2023 14:41:48 -0800 Subject: [PATCH] update func GetBackupCandidates Signed-off-by: Jun Wang --- go/vt/vtctl/reparentutil/util.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/go/vt/vtctl/reparentutil/util.go b/go/vt/vtctl/reparentutil/util.go index 2f6f846e793..0dca8627e3b 100644 --- a/go/vt/vtctl/reparentutil/util.go +++ b/go/vt/vtctl/reparentutil/util.go @@ -346,6 +346,16 @@ func waitForCatchUp( // GetBackupCandidates is used to get a list of healthy tablets for backup func GetBackupCandidates(tablets []*topo.TabletInfo, stats []*replicationdatapb.Status) (res []*topo.TabletInfo) { + // In case of all tablets has nil stats, return TabletType_PRIMARY + if len(stats) == 0 { + for _, tablet := range tablets { + if tablet.Type == topodatapb.TabletType_PRIMARY { + res = append(res, tablet) + break + } + } + return res + } for i, stat := range stats { // Always include TabletType_PRIMARY if tablets[i].Type == topodatapb.TabletType_PRIMARY {