{"record":{"id":"6d1d26cc2cffacc1","repo":"dgraph-io/dgraph","slug":"schema-state-not-found-for-s","errorCode":null,"errorMessage":"Schema state not found for %s.","messagePattern":"Schema state not found for (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/schema.go","lineNumber":388,"sourceCode":"\tisWrite, _ := ctx.Value(IsWrite).(bool)\n\ts.RLock()\n\tdefer s.RUnlock()\n\tvar su *pb.SchemaUpdate\n\tif isWrite {\n\t\tif schema, ok := s.mutSchema[pred]; ok {\n\t\t\tsu = schema\n\t\t}\n\t}\n\tif su == nil {\n\t\tif schema, ok := s.predicate[pred]; ok {\n\t\t\tsu = schema\n\t\t}\n\t}\n\tif su == nil {\n\t\t// This may happen when some query that needs indexing over this predicate is executing\n\t\t// while the predicate is dropped from the state (using drop operation).\n\t\tglog.Errorf(\"Schema state not found for %s.\", pred)\n\t\treturn nil, errors.Errorf(\"Schema state not found for %s.\", pred)\n\t}\n\tcreates := make([]*tok.FactoryCreateSpec, 0, len(su.IndexSpecs))\n\tfor _, vs := range su.IndexSpecs {\n\t\tc, err := tok.GetFactoryCreateSpecFromSpec(vs)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcreates = append(creates, c)\n\t}\n\treturn creates, nil\n}\n\n// VectorIndexNames returns the indexes for given predicate\nfunc (s *state) VectorIndexes(ctx context.Context, pred string) []string {\n\tvar names []string\n\tvectorIndexes, err := s.FactoryCreateSpec(ctx, pred)\n\tif err != nil {\n\t\tglog.Errorf(\"Vector Tokenizers error for %s: %s\", pred, err)","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/schema/schema.go#L370-L406","documentation":"FactoryCreateSpec builds vector-index tokenizer create specs for a predicate and needs the predicate's schema state (containing its IndexSpecs). If the schema unit is absent — typically because the predicate was dropped concurrently while an indexing-needing query was running — it logs and returns this error.","triggerScenarios":"A drop (DropAll/DropAttr) executing concurrently with a query that requires the vector index of the same predicate; calling FactoryCreateSpec for a predicate with no schema entry.","commonSituations":"Race between admin drop operations and running queries in multi-tenant/high-churn deployments; dropping an attribute while vector similarity queries are still in flight.","solutions":["Retry the operation after the drop completes; the schema state will be gone/rebuilt consistently","Serialize drop operations with index-dependent queries (application-level locking or retry-on-error)","Verify the predicate still exists in the schema before issuing vector queries against it","If the drop was unintended, re-apply the schema for that predicate"],"exampleFix":"// before\nspec, err := schema.FactoryCreateSpec(pred) // err: Schema state not found\n// after\nif err != nil {\n    if strings.Contains(err.Error(), \"Schema state not found\") {\n        return retryAfterBackoff(ctx, pred) // wait for drop to finish\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// ensure predicate exists before index-dependent work\nif _, err := schema.TypeOf(pred); err != nil {\n    return fmt.Errorf(\"predicate %q absent; cannot build index spec\", pred)\n}","typeGuard":null,"tryCatchPattern":"spec, err := schema.FactoryCreateSpec(pred)\nif err != nil {\n    if strings.Contains(err.Error(), \"Schema state not found\") {\n        return backoffRetry(ctx, func() error {\n            _, e := schema.FactoryCreateSpec(pred); return e\n        })\n    }\n    return err\n}","preventionTips":["Serialize drop operations with index-building/query paths","Use bounded exponential backoff for transient schema-state races","Confirm the predicate survives concurrent DropAttr before relying on its index"],"tags":["dgraph","schema","race-condition","vector-index"],"backgroundTag":"schema-state-missing-race","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}