From 806c8e6acc6e3ec90df3c1d053a9f1a1866b4f9c Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Tue, 3 Dec 2024 10:52:32 +0530 Subject: [PATCH] refactor: rename blocked to stalled Signed-off-by: Manan Gupta --- go/vt/vttablet/tabletmanager/rpc_replication.go | 6 +++--- go/vt/vttablet/tabletserver/controller.go | 4 ++-- go/vt/vttablet/tabletserver/state_manager.go | 8 ++++---- go/vt/vttablet/tabletserver/state_manager_test.go | 8 ++++---- go/vt/vttablet/tabletserver/tabletserver.go | 6 +++--- go/vt/vttablet/tabletservermock/controller.go | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/rpc_replication.go b/go/vt/vttablet/tabletmanager/rpc_replication.go index 7cb8caec844..49c8d0f7a7d 100644 --- a/go/vt/vttablet/tabletmanager/rpc_replication.go +++ b/go/vt/vttablet/tabletmanager/rpc_replication.go @@ -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])) diff --git a/go/vt/vttablet/tabletserver/controller.go b/go/vt/vttablet/tabletserver/controller.go index 9e13134ad17..c4a4bef99fc 100644 --- a/go/vt/vttablet/tabletserver/controller.go +++ b/go/vt/vttablet/tabletserver/controller.go @@ -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. diff --git a/go/vt/vttablet/tabletserver/state_manager.go b/go/vt/vttablet/tabletserver/state_manager.go index bcce3711439..1fc456b190e 100644 --- a/go/vt/vttablet/tabletserver/state_manager.go +++ b/go/vt/vttablet/tabletserver/state_manager.go @@ -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 @@ -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()) } diff --git a/go/vt/vttablet/tabletserver/state_manager_test.go b/go/vt/vttablet/tabletserver/state_manager_test.go index d8f316ad45c..7ffb46bbd6c 100644 --- a/go/vt/vttablet/tabletserver/state_manager_test.go +++ b/go/vt/vttablet/tabletserver/state_manager_test.go @@ -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, "") @@ -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() diff --git a/go/vt/vttablet/tabletserver/tabletserver.go b/go/vt/vttablet/tabletserver/tabletserver.go index 63a648fc37e..a3cd025bc9b 100644 --- a/go/vt/vttablet/tabletserver/tabletserver.go +++ b/go/vt/vttablet/tabletserver/tabletserver.go @@ -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. diff --git a/go/vt/vttablet/tabletservermock/controller.go b/go/vt/vttablet/tabletservermock/controller.go index 3281072fb6c..a5242751454 100644 --- a/go/vt/vttablet/tabletservermock/controller.go +++ b/go/vt/vttablet/tabletservermock/controller.go @@ -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.