Skip to content

Commit

Permalink
Revert "Add locking to concurrently-update bool"
Browse files Browse the repository at this point in the history
This reverts commit a9598fb.
  • Loading branch information
timvaillancourt committed Jun 6, 2024
1 parent e2a2149 commit 146f192
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions go/vt/vttablet/tabletmanager/rpc_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 146f192

Please sign in to comment.