dgraph-io/dgraph · critical
cannot load schema after streaming data
Error message
cannot load schema after streaming data
What it means
After an external snapshot stream is flushed into BadgerDB, postStreamProcessing reloads the in-memory schema from the freshly written postings via schema.LoadFromDb. If that load fails, the node's schema state would be inconsistent with the restored data, so the error wraps the underlying cause.
Source
Thrown at worker/import.go:498
// Receive the first message to check the Forward flag.
// If Forward is true, this node is the leader and should forward the stream to its followers.
// If Forward is false, the node just writes and flushes the data.
forwardReq, err := stream.Recv()
if err != nil {
return err
}
glog.Infof("[import] received forward flag: %v", forwardReq.Forward)
return streamInGroup(stream, forwardReq.Forward)
}
// postStreamProcessing handles the post-stream processing of data received from the buffer into the local BadgerDB.
// It loads the schema, updates the membership state, informs zero about tablets, resets caches, applies initial schema,
// applies initial types, and resets the GQL schema store.
func postStreamProcessing(ctx context.Context) error {
glog.Info("[import:flush] post stream processing")
if err := schema.LoadFromDb(ctx); err != nil {
return errors.Wrapf(err, "cannot load schema after streaming data")
}
if err := UpdateMembershipState(ctx); err != nil {
return errors.Wrapf(err, "cannot update membership state after streaming data")
}
gr.informZeroAboutTablets()
posting.ResetCache()
ResetAclCache()
groups().applyInitialSchema()
groups().applyInitialTypes()
ResetGQLSchemaStore()
glog.Info("[import:flush] post stream processing done")
return nil
}
// streamInGroup handles the streaming of data within a group.
// This function is called on both leader and follower nodes with different behaviors:
// - Leader (forward=true): The leader node receives data and forwards it to all group membersView on GitHub (pinned to 759e242be6)
Solutions
- Inspect the wrapped cause (errors.Cause) and fix the underlying Badger/IO issue (disk space, permissions, corruption).
- Re-run the external snapshot import from a clean snapshot to get consistent data.
- Check node disk health and Badger directory for leftover/partial files.
- Increase client timeout so the post-processing context is not canceled.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// check disk space and context before import post-processing
if freeDisk(postingsDir) < requiredBytes { return errors.New("insufficient disk for snapshot restore") }
if ctx.Err() != nil { return ctx.Err() } Try / catch
if err := runImport(ctx); err != nil {
var wrapped interface{ Cause() error }
if errors.As(err, &target) && strings.Contains(err.Error(), "cannot load schema after streaming") {
// inspect root cause: badger/IO failure; consider full re-import
}
} Prevention
- Monitor disk space on Badger directories before/during imports
- Avoid canceling import contexts during flush/post-processing
- Use journal drains and clean snapshots so partial data cannot corrupt schema load
When it happens
Trigger: schema.LoadFromDb fails right after streaming snapshot data — typically due to Badger/IO errors reading the posting layer, corrupted or partially flushed snapshot data, or the context being canceled mid-load.
Common situations: Disk full or corruption during snapshot restore; node crashed/restarted during a previous import leaving partial data; context canceled because the import caller timed out.
Related errors
- could not read list part with key %s
- cannot unmarshal list part with key %s
- Error while updating GraphQL schema.
- while updating persisted query's schema
- cannot export data inside DB at %s
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/8ef78be1c5a7192d.
Report an issue: GitHub.