From 743db0977fad8cccbd7ae4e305e65ac0be0d75a0 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Mon, 16 Dec 2024 17:00:46 +0530 Subject: [PATCH] feat: add a constant error for demote primary stall Signed-off-by: Manan Gupta --- go/vt/vterrors/code.go | 3 +++ go/vt/vttablet/tabletserver/state_manager.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/go/vt/vterrors/code.go b/go/vt/vterrors/code.go index 31c98cef280..85ff051d8f9 100644 --- a/go/vt/vterrors/code.go +++ b/go/vt/vterrors/code.go @@ -102,6 +102,7 @@ var ( VT09028 = errorWithState("VT09028", vtrpcpb.Code_FAILED_PRECONDITION, CTERecursiveForbiddenJoinOrder, "In recursive query block of Recursive Common Table Expression '%s', the recursive table must neither be in the right argument of a LEFT JOIN, nor be forced to be non-first with join order hints", "") VT09029 = errorWithState("VT09029", vtrpcpb.Code_FAILED_PRECONDITION, CTERecursiveRequiresSingleReference, "In recursive query block of Recursive Common Table Expression %s, the recursive table must be referenced only once, and not in any subquery", "") VT09030 = errorWithState("VT09030", vtrpcpb.Code_FAILED_PRECONDITION, CTEMaxRecursionDepth, "Recursive query aborted after 1000 iterations.", "") + VT09031 = errorWithoutState("VT09031", vtrpcpb.Code_FAILED_PRECONDITION, "Failed to complete primary demotion", "") VT10001 = errorWithoutState("VT10001", vtrpcpb.Code_ABORTED, "foreign key constraints are not allowed", "Foreign key constraints are not allowed, see https://vitess.io/blog/2021-06-15-online-ddl-why-no-fk/.") VT10002 = errorWithoutState("VT10002", vtrpcpb.Code_ABORTED, "atomic distributed transaction not allowed: %s", "The distributed transaction cannot be committed. A rollback decision is taken.") @@ -192,6 +193,8 @@ var ( VT09027, VT09028, VT09029, + VT09030, + VT09031, VT10001, VT10002, VT12001, diff --git a/go/vt/vttablet/tabletserver/state_manager.go b/go/vt/vttablet/tabletserver/state_manager.go index 1fc456b190e..bd1082d36f4 100644 --- a/go/vt/vttablet/tabletserver/state_manager.go +++ b/go/vt/vttablet/tabletserver/state_manager.go @@ -718,7 +718,7 @@ func (sm *stateManager) Broadcast() { lag, err := sm.refreshReplHealthLocked() 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") + err = vterrors.VT09031() } sm.hs.ChangeState(sm.target.TabletType, sm.ptsTimestamp, lag, err, sm.isServingLocked()) }