Skip to content

Commit

Permalink
refactor: rename blocked to stalled
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Dec 3, 2024
1 parent fcfd133 commit 0c20bed
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletmanager/rpc_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ func (tm *TabletManager) demotePrimary(ctx context.Context, revertPartialFailure
// Finished running DemotePrimary. Nothing to do.
case <-time.After(10 * topo.RemoteOperationTimeout):
// We waited for over 10 times of remote operation timeout, but DemotePrimary is still not done.
// Collect more information and signal demote primary is indefinitely stuck.
log.Errorf("DemotePrimary seems to be blocked. Collecting more information.")
tm.QueryServiceControl.SetDemotePrimaryBlocked()
// Collect more information and signal demote primary is indefinitely stalled.
log.Errorf("DemotePrimary seems to be stalled. Collecting more information.")
tm.QueryServiceControl.SetDemotePrimaryStalled()
buf := make([]byte, 1<<16) // 64 KB buffer size
stackSize := runtime.Stack(buf, true)
log.Errorf("Stack trace:\n%s", string(buf[:stackSize]))
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ type Controller interface {
// WaitForPreparedTwoPCTransactions waits for all prepared transactions to be resolved.
WaitForPreparedTwoPCTransactions(ctx context.Context) error

// SetDemotePrimaryBlocked marks that demote primary is blocked in the state manager.
SetDemotePrimaryBlocked()
// SetDemotePrimaryStalled marks that demote primary is stalled in the state manager.
SetDemotePrimaryStalled()
}

// Ensure TabletServer satisfies Controller interface.
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletserver/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type stateManager struct {
ptsTimestamp time.Time
retrying bool
replHealthy bool
demotePrimaryBlocked bool
demotePrimaryStalled bool
lameduck bool
alsoAllow []topodatapb.TabletType
reason string
Expand Down Expand Up @@ -716,9 +716,9 @@ func (sm *stateManager) Broadcast() {
defer sm.mu.Unlock()

lag, err := sm.refreshReplHealthLocked()
if sm.demotePrimaryBlocked {
// If we are blocked from demoting primary, we should send an error for it.
err = vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "Demoting primary is blocked")
if sm.demotePrimaryStalled {
// If we are stalled while demoting primary, we should send an error for it.
err = vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "Failed to complete primary demotion")
}
sm.hs.ChangeState(sm.target.TabletType, sm.ptsTimestamp, lag, err, sm.isServingLocked())
}
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletserver/state_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ func TestStateManagerNotify(t *testing.T) {
sm.StopService()
}

func TestDemotePrimaryBlocked(t *testing.T) {
func TestDemotePrimaryStalled(t *testing.T) {
sm := newTestStateManager()
defer sm.StopService()
err := sm.SetServingType(topodatapb.TabletType_PRIMARY, testNow, StateServing, "")
Expand All @@ -695,11 +695,11 @@ func TestDemotePrimaryBlocked(t *testing.T) {
gotshr := <-ch
require.Empty(t, gotshr.RealtimeStats.HealthError)

// If demote primary is blocked, then we should get an error.
sm.demotePrimaryBlocked = true
// If demote primary is stalled, then we should get an error.
sm.demotePrimaryStalled = true
sm.Broadcast()
gotshr = <-ch
require.EqualValues(t, "Demoting primary is blocked", gotshr.RealtimeStats.HealthError)
require.EqualValues(t, "Failed to complete primary demotion", gotshr.RealtimeStats.HealthError)

// Stop the state manager.
sm.StopService()
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,9 @@ func (tsv *TabletServer) WaitForPreparedTwoPCTransactions(ctx context.Context) e
}
}

// SetDemotePrimaryBlocked marks that demote primary is blocked in the state manager.
func (tsv *TabletServer) SetDemotePrimaryBlocked() {
tsv.sm.demotePrimaryBlocked = true
// SetDemotePrimaryStalled marks that demote primary is stalled in the state manager.
func (tsv *TabletServer) SetDemotePrimaryStalled() {
tsv.sm.demotePrimaryStalled = true
}

// CreateTransaction creates the metadata for a 2PC transaction.
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletservermock/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ func (tqsc *Controller) WaitForPreparedTwoPCTransactions(context.Context) error
return nil
}

// SetDemotePrimaryBlocked is part of the tabletserver.Controller interface
func (tqsc *Controller) SetDemotePrimaryBlocked() {
tqsc.MethodCalled["SetDemotePrimaryBlocked"] = true
// SetDemotePrimaryStalled is part of the tabletserver.Controller interface
func (tqsc *Controller) SetDemotePrimaryStalled() {
tqsc.MethodCalled["SetDemotePrimaryStalled"] = true
}

// EnterLameduck implements tabletserver.Controller.
Expand Down

0 comments on commit 0c20bed

Please sign in to comment.