{"record":{"id":"77412d765ba8943c","repo":"vitessio/vitess","slug":"durability-policy-v-not-found","errorCode":null,"errorMessage":"durability policy %v not found","messagePattern":"durability policy (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/reparentutil/policy/durability.go","lineNumber":111,"sourceCode":"\t// HasSemiSync returns whether the durability policy uses semi-sync.\n\tHasSemiSync() bool\n}\n\nfunc RegisterDurability(name string, newDurablerFunc NewDurabler) {\n\tif durabilityPolicies[name] != nil {\n\t\tlog.Error(fmt.Sprintf(\"durability policy %v already registered\", name))\n\t\tos.Exit(1)\n\t}\n\tdurabilityPolicies[name] = newDurablerFunc\n}\n\n//=======================================================================\n\n// GetDurabilityPolicy is used to get a new durability policy from the registered policies\nfunc GetDurabilityPolicy(name string) (Durabler, error) {\n\tnewDurabilityCreationFunc, found := durabilityPolicies[name]\n\tif !found {\n\t\treturn nil, fmt.Errorf(\"durability policy %v not found\", name)\n\t}\n\treturn newDurabilityCreationFunc(), nil\n}\n\n// CheckDurabilityPolicyExists is used to check if the durability policy is part of the registered policies\nfunc CheckDurabilityPolicyExists(name string) bool {\n\t_, found := durabilityPolicies[name]\n\treturn found\n}\n\n// PromotionRule returns the promotion rule for the instance.\nfunc PromotionRule(durability Durabler, tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {\n\t// Prevent panics.\n\tif tablet == nil || tablet.Alias == nil {\n\t\treturn promotionrule.MustNot\n\t}\n\treturn durability.PromotionRule(tablet)\n}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/reparentutil/policy/durability.go#L93-L129","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run vtctldclient GetKeyspace <ks> and check durabilityPolicy; correct it to a registered name (e.g., 'none' or 'semi_sync') via vtctldclient SetKeyspaceDurabilityPolicy","List/confirm valid policy names in go/vt/vtctl/reparentutil/policy (registered in init)","If a custom policy is required, register its creation func in policy.durabilityPolicies before use","Fix environment/version mismatch: align the cluster version that supports the configured policy name"],"exampleFix":"// before\nvtctldclient CreateKeyspace --durability-policy=semisync commerce\n// after\nvtctldclient CreateKeyspace --durability-policy=semi_sync commerce\n# or fix an existing keyspace:\nvtctldclient SetKeyspaceDurabilityPolicy commerce semi_sync","handlingStrategy":"validation","validationCode":"// Validate durability policy before creating/updating a keyspace\nif !policy.CheckDurabilityPolicyExists(name) {\n\treturn fmt.Errorf(\"unknown durability policy %q; use a registered name\", name)\n}","typeGuard":null,"tryCatchPattern":"_, err := policy.GetDurabilityPolicy(name)\nif err != nil {\n\t// fall back to a known policy (e.g. \"none\") after logging, or fail fast with the list of valid names\n}","preventionTips":["Use only documented policy names (none, semi_sync)","Check GetKeyspace output after SetKeyspaceDurabilityPolicy changes","Register custom Durabler implementations in init()","Pin config to policy names supported by your Vitess version"],"tags":["durability","reparent","config"],"backgroundTag":"invalid-durability-policy","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}