vitessio/vitess · error

durability policy %v not found

Error message

durability policy %v not found

What it means

GetDurabilityPolicy looks up a registered durability policy by name and errors when the name is not in the registry. Vitess only knows built-in policies (e.g., 'none', 'semi_sync') registered at init time; any other value is rejected before any reparent or tablet-type logic runs.

Source

Thrown at go/vt/vtctl/reparentutil/policy/durability.go:111

	// HasSemiSync returns whether the durability policy uses semi-sync.
	HasSemiSync() bool
}

func RegisterDurability(name string, newDurablerFunc NewDurabler) {
	if durabilityPolicies[name] != nil {
		log.Error(fmt.Sprintf("durability policy %v already registered", name))
		os.Exit(1)
	}
	durabilityPolicies[name] = newDurablerFunc
}

//=======================================================================

// GetDurabilityPolicy is used to get a new durability policy from the registered policies
func GetDurabilityPolicy(name string) (Durabler, error) {
	newDurabilityCreationFunc, found := durabilityPolicies[name]
	if !found {
		return nil, fmt.Errorf("durability policy %v not found", name)
	}
	return newDurabilityCreationFunc(), nil
}

// CheckDurabilityPolicyExists is used to check if the durability policy is part of the registered policies
func CheckDurabilityPolicyExists(name string) bool {
	_, found := durabilityPolicies[name]
	return found
}

// PromotionRule returns the promotion rule for the instance.
func PromotionRule(durability Durabler, tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
	// Prevent panics.
	if tablet == nil || tablet.Alias == nil {
		return promotionrule.MustNot
	}
	return durability.PromotionRule(tablet)
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Run vtctldclient GetKeyspace <ks> and check durabilityPolicy; correct it to a registered name (e.g., 'none' or 'semi_sync') via vtctldclient SetKeyspaceDurabilityPolicy
  2. List/confirm valid policy names in go/vt/vtctl/reparentutil/policy (registered in init)
  3. If a custom policy is required, register its creation func in policy.durabilityPolicies before use
  4. Fix environment/version mismatch: align the cluster version that supports the configured policy name

Example fix

// before
vtctldclient CreateKeyspace --durability-policy=semisync commerce
// after
vtctldclient CreateKeyspace --durability-policy=semi_sync commerce
# or fix an existing keyspace:
vtctldclient SetKeyspaceDurabilityPolicy commerce semi_sync
Defensive patterns

Strategy: validation

Validate before calling

// Validate durability policy before creating/updating a keyspace
if !policy.CheckDurabilityPolicyExists(name) {
	return fmt.Errorf("unknown durability policy %q; use a registered name", name)
}

Try / catch

_, err := policy.GetDurabilityPolicy(name)
if err != nil {
	// fall back to a known policy (e.g. "none") after logging, or fail fast with the list of valid names
}

Prevention

When it happens

Trigger: Keyspace's DurabilityPolicy field holds an unknown name (typo, custom policy never registered, value from a newer/older Vitess version), consumed by ChangeTabletType, InitShardPrimaryLocked, ReparentTablet, StartReplication, TabletExternallyReparented, or planner anonymous callers.

Common situations: Typo in keyspace CreateKeyspace --durability-policy; upgrading/downgrading Vitess where a policy name changed; attempting to use a custom Durabler without registering it in durabilityPolicies; config drift where keyspace was created with an invalid value.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/77412d765ba8943c. Report an issue: GitHub.