From a044d9181c99769a8e49a6ba843dfee353f4d2b0 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Mon, 8 Jul 2024 20:28:04 +0200 Subject: [PATCH] reorder shard lock Signed-off-by: Tim Vaillancourt --- go/vt/vttablet/tabletmanager/rpc_replication.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/rpc_replication.go b/go/vt/vttablet/tabletmanager/rpc_replication.go index 3aed26a5d16..953651f69a8 100644 --- a/go/vt/vttablet/tabletmanager/rpc_replication.go +++ b/go/vt/vttablet/tabletmanager/rpc_replication.go @@ -707,13 +707,6 @@ func (tm *TabletManager) setReplicationSourceRepairReplication(ctx context.Conte return err } - ctx, unlock, lockErr := tm.TopoServer.LockShard(ctx, parent.Tablet.GetKeyspace(), parent.Tablet.GetShard(), fmt.Sprintf("repairReplication to %v as parent)", topoproto.TabletAliasString(parentAlias))) - if lockErr != nil { - return lockErr - } - - defer unlock(&err) - currentPrimary, err := tm.TopoServer.GetTablet(ctx, parentAlias) if err != nil { return vterrors.Wrapf(err, "cannot read primary tablet %v", parentAlias) @@ -736,6 +729,13 @@ func (tm *TabletManager) setReplicationSourceRepairReplication(ctx context.Conte return err } + ctx, unlock, lockErr := tm.TopoServer.LockShard(ctx, parent.Tablet.GetKeyspace(), parent.Tablet.GetShard(), fmt.Sprintf("repairReplication to %v as parent)", topoproto.TabletAliasString(parentAlias))) + if lockErr != nil { + return lockErr + } + + defer unlock(&err) + return tm.setReplicationSourceLocked(ctx, parentAlias, timeCreatedNS, waitPosition, forceStartReplication, semiSyncAction) }