From 1b333dbed4dd57b40aeee952d76451921390910a Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Mon, 29 Jul 2024 17:44:25 +0200 Subject: [PATCH] `slack-15.0`: reset semi-sync in `setReplicationSourceRepairReplication` (#442) * `slack-15.0`: reset semi-sync in `setReplicationSourceRepairReplication` Signed-off-by: Tim Vaillancourt * reorder shard lock Signed-off-by: Tim Vaillancourt * try 100% percona-xtrabackup-80 Signed-off-by: Tim Vaillancourt * Revert "try 100% percona-xtrabackup-80" This reverts commit e67be76f3a223b529bb72acb452fc321a83d3808. * percona-xtrabackup-24 problem fix attempt 2 Signed-off-by: Tim Vaillancourt * remove currentPrimary Signed-off-by: Tim Vaillancourt * empty commit to fix CI --------- Signed-off-by: Tim Vaillancourt --- .../vttablet/tabletmanager/rpc_replication.go | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/go/vt/vttablet/tabletmanager/rpc_replication.go b/go/vt/vttablet/tabletmanager/rpc_replication.go index 3ef6b543f3c..2adde1a1bed 100644 --- a/go/vt/vttablet/tabletmanager/rpc_replication.go +++ b/go/vt/vttablet/tabletmanager/rpc_replication.go @@ -31,6 +31,7 @@ import ( "vitess.io/vitess/go/vt/mysqlctl" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/topo/topoproto" + "vitess.io/vitess/go/vt/vtctl/reparentutil" "vitess.io/vitess/go/vt/vterrors" replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata" @@ -706,6 +707,23 @@ func (tm *TabletManager) setReplicationSourceRepairReplication(ctx context.Conte return err } + durabilityName, err := tm.TopoServer.GetKeyspaceDurability(ctx, tm.Tablet().Keyspace) + if err != nil { + return vterrors.Wrapf(err, "cannot read keyspace durability policy %v", tm.Tablet().Keyspace) + } + log.Infof("Getting a new durability policy for %v", durabilityName) + durability, err := reparentutil.GetDurabilityPolicy(durabilityName) + if err != nil { + return vterrors.Wrapf(err, "cannot get durability policy %v", durabilityName) + } + + // If using semi-sync, we need to enable it before connecting to primary. + // We should set the correct type, since it is used in replica semi-sync. + semiSyncAction, err := tm.convertBoolToSemiSyncAction(reparentutil.IsReplicaSemiSync(durability, parent.Tablet, tm.Tablet())) + if err != nil { + 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 @@ -713,7 +731,7 @@ func (tm *TabletManager) setReplicationSourceRepairReplication(ctx context.Conte defer unlock(&err) - return tm.setReplicationSourceLocked(ctx, parentAlias, timeCreatedNS, waitPosition, forceStartReplication, SemiSyncActionNone) + return tm.setReplicationSourceLocked(ctx, parentAlias, timeCreatedNS, waitPosition, forceStartReplication, semiSyncAction) } func (tm *TabletManager) setReplicationSourceSemiSyncNoAction(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool) error {