From cdca70e98dfdcf70ccbcda5523f5c0da3bd77c02 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Fri, 29 Apr 2022 13:29:54 +0530 Subject: [PATCH] feat: fix ReplicaWasRunning so that it doesn't have code dependent on the upgrade Signed-off-by: Manan Gupta --- go/vt/vtctl/reparentutil/replication.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/go/vt/vtctl/reparentutil/replication.go b/go/vt/vtctl/reparentutil/replication.go index a62a45b2ddd..63403f7c70e 100644 --- a/go/vt/vtctl/reparentutil/replication.go +++ b/go/vt/vtctl/reparentutil/replication.go @@ -150,12 +150,9 @@ func ReplicaWasRunning(stopStatus *replicationdatapb.StopReplicationStatus) (boo return false, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "could not determine Before state of StopReplicationStatus %v", stopStatus) } - // v13 and older tablets will only provide the binary IoThreadRunning and - // SqlThreadRunning values while v14 and newer tablets will provide the - // non-binary replication states. - // This backwards compatible check can be removed in v15+. - return ((stopStatus.Before.IoState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.IoThreadRunning) || - (stopStatus.Before.SqlState == int32(mysql.ReplicationStateRunning) || stopStatus.Before.SqlThreadRunning)), nil + replStatus := mysql.ProtoToReplicationStatus(stopStatus.Before) + return (replStatus.IOState == mysql.ReplicationStateRunning) || + (replStatus.SQLState == mysql.ReplicationStateRunning), nil } // SetReplicationSource is used to set the replication source on the specified