Skip to content

Commit

Permalink
feat: add few more changes for safety
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Dec 18, 2024
1 parent e278e11 commit 0b8c3f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (sm *stateManager) StartRequest(ctx context.Context, target *querypb.Target
sm.mu.Lock()
defer sm.mu.Unlock()

if sm.state != StateServing || !sm.replHealthy {
if sm.state != StateServing || !sm.replHealthy || sm.demotePrimaryStalled {
// This specific error string needs to be returned for vtgate buffering to work.
return vterrors.New(vtrpcpb.Code_CLUSTER_EVENT, vterrors.NotServing)
}
Expand Down Expand Up @@ -777,7 +777,7 @@ func (sm *stateManager) IsServing() bool {
}

func (sm *stateManager) isServingLocked() bool {
return sm.state == StateServing && sm.wantState == StateServing && sm.replHealthy && !sm.lameduck
return sm.state == StateServing && sm.wantState == StateServing && sm.replHealthy && !sm.demotePrimaryStalled && !sm.lameduck
}

func (sm *stateManager) AppendDetails(details []*kv) []*kv {
Expand Down
3 changes: 3 additions & 0 deletions go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,10 @@ func (tsv *TabletServer) WaitForPreparedTwoPCTransactions(ctx context.Context) e

// SetDemotePrimaryStalled marks that demote primary is stalled in the state manager.
func (tsv *TabletServer) SetDemotePrimaryStalled() {
tsv.sm.mu.Lock()
tsv.sm.demotePrimaryStalled = true
tsv.sm.mu.Unlock()
tsv.BroadcastHealth()
}

// CreateTransaction creates the metadata for a 2PC transaction.
Expand Down

0 comments on commit 0b8c3f4

Please sign in to comment.