diff --git a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go index 569a311f97f..b4dbaf0d101 100644 --- a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go +++ b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go @@ -142,6 +142,10 @@ func TestEmergencyReparenter_reparentShardLocked(t *testing.T) { Error: nil, }, }, + SetMasterResults: map[string]error{ + "zone1-0000000100": nil, + "zone1-0000000101": nil, + }, StopReplicationAndGetStatusResults: map[string]struct { Status *replicationdatapb.Status StopStatus *replicationdatapb.StopReplicationStatus @@ -240,6 +244,10 @@ func TestEmergencyReparenter_reparentShardLocked(t *testing.T) { Error: nil, }, }, + SetMasterResults: map[string]error{ + "zone1-0000000100": nil, + "zone1-0000000102": nil, + }, StopReplicationAndGetStatusResults: map[string]struct { Status *replicationdatapb.Status StopStatus *replicationdatapb.StopReplicationStatus diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index 4644b0b6246..0c1d7864329 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -142,6 +142,10 @@ func FindValidEmergencyReparentCandidates( // ReplicaWasRunning returns true if a StopReplicationStatus indicates that the // replica had running replication threads before being stopped. func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) bool { + if stopStatus.Before == nil { + return false + } + return stopStatus.Before.IoThreadRunning || stopStatus.Before.SqlThreadRunning } diff --git a/go/vt/vtctl/reparentutil/replication_test.go b/go/vt/vtctl/reparentutil/replication_test.go index 0b8c3de6997..01527393b7f 100644 --- a/go/vt/vtctl/reparentutil/replication_test.go +++ b/go/vt/vtctl/reparentutil/replication_test.go @@ -760,6 +760,13 @@ func TestReplicaWasRunning(t *testing.T) { }, expected: false, }, + { + name: "status.Before is nil means we were not running", + in: &replicationdatapb.StopReplicationStatus{ + Before: nil, + }, + expected: false, + }, } for _, tt := range tests {