{"record":{"id":"aa558f560d53f30a","repo":"vitessio/vitess","slug":"savevschema-v-failed-v","errorCode":null,"errorMessage":"SaveVSchema(%v) failed: %v","messagePattern":"SaveVSchema\\((.+?)\\) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtcombo/tablet_map.go","lineNumber":418,"sourceCode":"\tif schemaDir != \"\" {\n\t\tf := path.Join(schemaDir, keyspace, \"vschema.json\")\n\t\tif _, err := os.Stat(f); err == nil {\n\t\t\t// load the vschema\n\t\t\tformal, err := vindexes.LoadFormalKeyspace(f)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"cannot load vschema file %v for keyspace %v: %v\", f, keyspace, err)\n\t\t\t}\n\n\t\t\t_, err = vindexes.BuildKeyspace(formal, wr.SQLParser())\n\t\t\tif err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"BuildKeyspace(%v) failed: %v\", keyspace, err)\n\t\t\t}\n\t\t\tksvs := &topo.KeyspaceVSchemaInfo{\n\t\t\t\tName:     keyspace,\n\t\t\t\tKeyspace: formal,\n\t\t\t}\n\t\t\tif err := ts.SaveVSchema(ctx, ksvs); err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"SaveVSchema(%v) failed: %v\", keyspace, err)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Info(fmt.Sprintf(\"File %v doesn't exist, skipping vschema for keyspace %v\", f, keyspace))\n\t\t}\n\t}\n\n\t// Rebuild the SrvKeyspace object, so we can support\n\t// range-based sharding queries, and export the redirects.\n\tif err := topotools.RebuildKeyspace(ctx, wr.Logger(), wr.TopoServer(), keyspace, nil, false); err != nil {\n\t\treturn 0, fmt.Errorf(\"cannot rebuild %v: %v\", keyspace, err)\n\t}\n\treturn uid, nil\n}\n\n//\n// TabletConn implementation\n//\n","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtcombo/tablet_map.go#L400-L436","documentation":"CreateKs persists the loaded keyspace VSchema to the topo server via ts.SaveVSchema. This error means the vschema was valid but writing it to topology storage failed — a topo server connectivity/permission/consistency problem, not a vschema problem.","triggerScenarios":"CreateKs when the topo server (etcd/zk/consul/file backend) is unreachable, the session times out, the topo connection credentials are wrong, or the keyspace record was concurrently deleted/locked.","commonSituations":"etcd/zookeeper down or misconfigured in local-vt combo setups; topo server request timeouts under load; topo data manually wiped while vtcombo is initializing; network partition to remote topo.","solutions":["Check topo server health (etcdctl/zkCli connectivity) and vtcombo's -topo_* flags.","Inspect the wrapped error for topo timeouts vs permissions.","Re-run CreateKs / restart vtcombo once topo is reachable — saving vschema is idempotent.","Verify the keyspace record exists in topo and there are no conflicting writers."],"exampleFix":"// before\nvtcombo -topo_implementation=etcd2 -topo_server_addr=badhost:2379 ...\n// after\nvtcombo -topo_implementation=etcd2 -topo_server_addr=127.0.0.1:2379 ...","handlingStrategy":"retry","validationCode":"// verify topo reachability before CreateKs\nts, err := topo.OpenServer(topoImpl, serverAddr, root)\nif err != nil {\n\treturn fmt.Errorf(\"topo unavailable: %w\", err)\n}\nif _, err := ts.GetKeyspace(ctx, keyspace); err != nil && !topo.IsErrType(err, topodata.KeyspaceId) && !topo.IsNotFound(err) {\n\treturn fmt.Errorf(\"topo not usable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := CreateKs(...)\nif err != nil && strings.Contains(err.Error(), \"SaveVSchema\") {\n\t// topo write failed; wait for topo and retry — SaveVSchema is idempotent\n\tbackoff.Retry(ctx, func() error { return CreateKs(...) })\n}","preventionTips":["Health-check etcd/zk/consul before vtcombo startup","Keep topo server and vtcombo in the same failure domain in test setups","Re-run keyspace creation on topo recovery — it is safe to retry","Audit topo credentials/ACLs if writes consistently fail"],"tags":["topo","etcd","vtcombo"],"backgroundTag":"topo-write-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}