{"record":{"id":"dc3d0273b80b6c32","repo":"dgraph-io/dgraph","slug":"schema-state-not-found-for-s-dc3d02","errorCode":null,"errorMessage":"Schema state not found for %s.","messagePattern":"Schema state not found for (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/tokens.go","lineNumber":86,"sourceCode":"\tif funcType == ngramFn {\n\t\tif query {\n\t\t\treturn tok.GetNGramQueryTokens(funcArgs, lang)\n\t\t} else {\n\t\t\treturn tok.GetNGramTokens(funcArgs, lang)\n\t\t}\n\t}\n\treturn tok.GetTermTokens(funcArgs)\n}\n\nfunc pickTokenizer(ctx context.Context, attr string, f string) (tok.Tokenizer, error) {\n\t// Get the tokenizers and choose the corresponding one.\n\tif !schema.State().IsIndexed(ctx, attr) {\n\t\treturn nil, errors.Errorf(\"Attribute %s is not indexed.\", attr)\n\t}\n\n\ttokenizers := schema.State().Tokenizer(ctx, attr)\n\tif tokenizers == nil {\n\t\treturn nil, errors.Errorf(\"Schema state not found for %s.\", attr)\n\t}\n\tfor _, t := range tokenizers {\n\t\t// If function is eq and we found a tokenizer that's !Lossy(), lets return it\n\t\tswitch f {\n\t\tcase \"eq\":\n\t\t\t// For equality, find a non-lossy tokenizer.\n\t\t\tif !t.IsLossy() {\n\t\t\t\treturn t, nil\n\t\t\t}\n\t\tdefault:\n\t\t\t// rest of the cases: ge, gt, le, lt require a sortable tokenizer.\n\t\t\tif t.IsSortable() {\n\t\t\t\treturn t, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// Should we return an error if we don't find a non-lossy tokenizer for eq function.","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/tokens.go#L68-L104","documentation":"After confirming the attribute is indexed, pickTokenizer calls schema.State().Tokenizer to fetch the tokenizer list; if it comes back nil despite the attribute being indexed, this error is thrown. It indicates the in-memory schema state lacks tokenizer metadata for a predicate that IsIndexed claims is indexed.","triggerScenarios":"An indexed predicate whose schema entry has no tokenizer entry — typically a race or inconsistency between schema state and the tokenizer registry, e.g. querying during/just after a schema mutation, or a predicate indexed in one way that lost its tokenizer metadata.","commonSituations":"Concurrent schema alterations while queries run; cluster where a node has stale/partial schema state; predicates with index types that do not map to string tokenizers (note: for non-string indexed predicates hitting compare functions, the not-indexed or no-proper-index errors are more typical).","solutions":["Retry the query after the schema mutation settles; if it persists, restart/rebalance so nodes reload a consistent schema.","Re-apply the schema alteration (drop and re-add the index) so tokenizer metadata is rebuilt.","Check cluster schema consistency (all nodes report the same schema) and fix stale nodes."],"exampleFix":"// before: predicate altered while queries in flight\n// after: re-apply schema and retry\nawait dgraph.Alter(ctx, \"name: string @index(exact) .\")\n// then run the eq query","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := runQuery(ctx)\nif err != nil && strings.Contains(err.Error(), \"Schema state not found\") {\n    time.Sleep(backoff)\n    err = runQuery(ctx) // retry after schema state settles\n}","preventionTips":["Avoid running queries concurrently with schema alterations where possible.","Ensure all cluster nodes have converged on the same schema after mutations.","Re-apply index alterations if tokenizer metadata appears lost."],"tags":["dgraph","schema","tokenizer","consistency"],"backgroundTag":"schema-state-not-found","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}