{"record":{"id":"c0e39d93c1ecd65d","repo":"vitessio/vitess","slug":"keyspace-not-found","errorCode":null,"errorMessage":"keyspace not found","messagePattern":"keyspace not found","errorType":"error_code","errorClass":"ErrKeyspaceNotFound","httpStatus":null,"severity":"error","filePath":"go/vt/vtorc/inst/keyspace_dao.go","lineNumber":31,"sourceCode":"See the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage inst\n\nimport (\n\t\"errors\"\n\n\t\"vitess.io/vitess/go/vt/external/golib/sqlutils\"\n\ttopodatapb \"vitess.io/vitess/go/vt/proto/topodata\"\n\tvtorcdatapb \"vitess.io/vitess/go/vt/proto/vtorcdata\"\n\t\"vitess.io/vitess/go/vt/topo\"\n\t\"vitess.io/vitess/go/vt/vtctl/reparentutil/policy\"\n\t\"vitess.io/vitess/go/vt/vtorc/db\"\n)\n\n// ErrKeyspaceNotFound is a fixed error message used when a keyspace is not found in the database.\nvar ErrKeyspaceNotFound = errors.New(\"keyspace not found\")\n\n// ReadKeyspace reads the vitess keyspace record.\nfunc ReadKeyspace(keyspaceName string) (*topo.KeyspaceInfo, error) {\n\tif err := topo.ValidateKeyspaceName(keyspaceName); err != nil {\n\t\treturn nil, err\n\t}\n\n\tquery := `select\n\t\t\tkeyspace_type,\n\t\t\tdurability_policy,\n\t\t\tdisable_emergency_reparent\n\t\tfrom\n\t\t\tvitess_keyspace\n\t\twhere\n\t\t\tkeyspace = ?`\n\targs := sqlutils.Args(keyspaceName)\n\n\tkeyspace := &topo.KeyspaceInfo{","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtorc/inst/keyspace_dao.go#L13-L49","documentation":"ErrKeyspaceNotFound is the sentinel error returned by ReadKeyspace when the vitess keyspace record is absent from the vtorc/topo-backed database. Callers compare with errors.Is to detect a missing keyspace versus a real failure.","triggerScenarios":"ReadKeyspace(keyspaceName) when no row for that keyspace exists — the keyspace was never created, was deleted, or the name is misspelled.","commonSituations":"Typo in --clusters_to_watch or keyspace configuration; keyspace dropped by vtctl while vtorc still references it; running vtorc against an empty/new cluster before keyspace creation.","solutions":["Verify the keyspace exists: vtctldclient GetKeyspace <name>.","Fix the keyspace name in vtorc configuration/flags.","Create the keyspace via vtctldclient CreateKeyspace if it should exist."],"exampleFix":"// before\nks, err := inst.ReadKeyspace(ksName)\nif err != nil { return err }\n// after\nks, err := inst.ReadKeyspace(ksName)\nif errors.Is(err, inst.ErrKeyspaceNotFound) {\n    return fmt.Errorf(\"keyspace %s does not exist; check spelling or create it\", ksName)\n} else if err != nil { return err }","handlingStrategy":"validation","validationCode":"if keyspaceName == \"\" {\n    return errors.New(\"keyspace name is required\")\n}\n// optionally verify existence first via topo server read","typeGuard":null,"tryCatchPattern":"ks, err := inst.ReadKeyspace(ksName)\nif errors.Is(err, inst.ErrKeyspaceNotFound) {\n    return handleMissingKeyspace(ksName) // create it or fix config\n} else if err != nil { return err }","preventionTips":["Verify keyspace names in vtorc flags/config against vtctldclient GetKeyspace.","Create keyspaces before pointing vtorc at them.","Use errors.Is against the sentinel instead of string matching."],"tags":["vtorc","keyspace","not-found","topology"],"backgroundTag":"entity-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}