From 146f192fb38d16596d2fccd11e219794d2bd036b Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Thu, 6 Jun 2024 18:33:03 +0200 Subject: [PATCH] Revert "Add locking to concurrently-update bool" This reverts commit a9598fb8efe4b2d6f1d970b3ffd3d8af5668511b. --- .../vttablet/tabletmanager/rpc_replication.go | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/rpc_replication.go b/go/vt/vttablet/tabletmanager/rpc_replication.go index e863947ceac..3ef6b543f3c 100644 --- a/go/vt/vttablet/tabletmanager/rpc_replication.go +++ b/go/vt/vttablet/tabletmanager/rpc_replication.go @@ -726,25 +726,12 @@ func (tm *TabletManager) setReplicationSourceSemiSyncNoAction(ctx context.Contex return tm.setReplicationSourceLocked(ctx, parentAlias, timeCreatedNS, waitPosition, forceStartReplication, SemiSyncActionNone) } -// isSetReplicationSourceLockedRunning returns true if setReplicationSourceLocked is running. -// A mutex is needed because _isSetReplicationSourceLockedRunning is accessed concurrently. -func (tm *TabletManager) isSetReplicationSourceLockedRunning() bool { - tm.mutex.Lock() - defer tm.mutex.Unlock() - return tm._isSetReplicationSourceLockedRunning -} - -// setReplicationSourceLockedRunning sets _isSetReplicationSourceLockedRunning under a lock. -// A mutex is needed because _isSetReplicationSourceLockedRunning is accessed concurrently. -func (tm *TabletManager) setReplicationSourceLockedRunning(running bool) { - tm.mutex.Lock() - defer tm.mutex.Unlock() - tm._isSetReplicationSourceLockedRunning = running -} - func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentAlias *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync SemiSyncAction) (err error) { - tm.setReplicationSourceLockedRunning(true) - defer tm.setReplicationSourceLockedRunning(false) + tm._isSetReplicationSourceLockedRunning = true + + defer func() { + tm._isSetReplicationSourceLockedRunning = false + }() // End orchestrator maintenance at the end of fixing replication. // This is a best effort operation, so it should happen in a goroutine @@ -1142,7 +1129,7 @@ func (tm *TabletManager) handleRelayLogError(err error) error { // repairReplication tries to connect this server to whoever is // the current primary of the shard, and start replicating. func (tm *TabletManager) repairReplication(ctx context.Context) error { - if tm.isSetReplicationSourceLockedRunning() { + if tm._isSetReplicationSourceLockedRunning { // we are actively setting replication source, // repairReplication will block due to higher // authority holding a shard lock (PRS on vtctld)