dgraph-io/dgraph · error

Schema state not found for %s.

Error message

Schema state not found for %s.

What it means

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.

Source

Thrown at schema/schema.go:388

	isWrite, _ := ctx.Value(IsWrite).(bool)
	s.RLock()
	defer s.RUnlock()
	var su *pb.SchemaUpdate
	if isWrite {
		if schema, ok := s.mutSchema[pred]; ok {
			su = schema
		}
	}
	if su == nil {
		if schema, ok := s.predicate[pred]; ok {
			su = schema
		}
	}
	if su == nil {
		// This may happen when some query that needs indexing over this predicate is executing
		// while the predicate is dropped from the state (using drop operation).
		glog.Errorf("Schema state not found for %s.", pred)
		return nil, errors.Errorf("Schema state not found for %s.", pred)
	}
	creates := make([]*tok.FactoryCreateSpec, 0, len(su.IndexSpecs))
	for _, vs := range su.IndexSpecs {
		c, err := tok.GetFactoryCreateSpecFromSpec(vs)
		if err != nil {
			return nil, err
		}
		creates = append(creates, c)
	}
	return creates, nil
}

// VectorIndexNames returns the indexes for given predicate
func (s *state) VectorIndexes(ctx context.Context, pred string) []string {
	var names []string
	vectorIndexes, err := s.FactoryCreateSpec(ctx, pred)
	if err != nil {
		glog.Errorf("Vector Tokenizers error for %s: %s", pred, err)

View on GitHub (pinned to 759e242be6)

Solutions

  1. Retry the operation after the drop completes; the schema state will be gone/rebuilt consistently
  2. Serialize drop operations with index-dependent queries (application-level locking or retry-on-error)
  3. Verify the predicate still exists in the schema before issuing vector queries against it
  4. If the drop was unintended, re-apply the schema for that predicate

Example fix

// before
spec, err := schema.FactoryCreateSpec(pred) // err: Schema state not found
// after
if err != nil {
    if strings.Contains(err.Error(), "Schema state not found") {
        return retryAfterBackoff(ctx, pred) // wait for drop to finish
    }
    return err
}
Defensive patterns

Strategy: retry

Validate before calling

// ensure predicate exists before index-dependent work
if _, err := schema.TypeOf(pred); err != nil {
    return fmt.Errorf("predicate %q absent; cannot build index spec", pred)
}

Try / catch

spec, err := schema.FactoryCreateSpec(pred)
if err != nil {
    if strings.Contains(err.Error(), "Schema state not found") {
        return backoffRetry(ctx, func() error {
            _, e := schema.FactoryCreateSpec(pred); return e
        })
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/6d1d26cc2cffacc1. Report an issue: GitHub.