dgraph-io/dgraph · error
Error while dropping depreciated preds/types.
Error message
Error while dropping depreciated preds/types.
What it means
This error wraps failures of dropDepreciated in fixCors, the final step of the 21.03 offline upgrade. dropDepreciated deletes deprecated predicates and types (old GraphQL-prefixed preds) from the restored badger DB. If those delete/iterate operations fail, the error is wrapped with this message.
Source
Thrown at upgrade/change_v21.03.0.go:382
}
for typ := range deprecatedTypes {
prefixes = append(prefixes, x.TypeKey(x.AttrInRootNamespace(typ)))
}
return db.DropPrefix(prefixes...)
}
// fixCors removes the internal predicates from the restored backup. This also appends CORS from
// dgraph.cors to GraphQL schema.
func fixCors(db *badger.DB) error {
glog.Infof("Fixing cors information in the restored backup.")
cors, err := getCors(db)
if err != nil {
return errors.Wrapf(err, "Error while getting cors from db.")
}
if err := updateGQLSchemaOffline(db, cors); err != nil {
return errors.Wrapf(err, "Error while updating GraphQL schema.")
}
return errors.Wrapf(dropDepreciated(db), "Error while dropping depreciated preds/types.")
}
// fixPersistedQuery, for the schema related to persisted query removes the deprecated field from
// the type and updates the index tokenizer for the predicate.
func fixPersistedQuery(db *badger.DB) error {
glog.Infof("Fixing persisted query schema in restored backup.")
update := func(entry *badger.Entry) error {
txn := db.NewTransactionAt(math.MaxUint64, true)
defer txn.Discard()
if err := txn.SetEntry(entry); err != nil {
return err
}
// Schema is written at version 1.
return txn.CommitAt(1, nil)
}
// Update the tokenizer in the schema.
su := pb.SchemaUpdate{View on GitHub (pinned to 759e242be6)
Solutions
- Read the wrapped inner error (%+v) to find the badger-level cause; fix it (disk space, permissions, I/O) and rerun the offline upgrade.
- Re-restore the backup from the original backup file into a fresh p directory and rerun the upgrade.
- Confirm the restored p directory is not open by another dgraph process; stop all processes and retry.
- If specific deprecated entries are corrupt, use badger tools to inspect/repair, or manually drop the affected preds before rerunning.
Example fix
// before dgraph upgrade offline -w v21.03.0 -d /var/lib/dgraph/p // after (ensure exclusive access and healthy disk) systemctl stop dgraph dgraph debug --badgerdir /var/lib/dgraph/p # verify integrity dgraph upgrade offline -w v21.03.0 -d /var/lib/dgraph/p
Defensive patterns
Strategy: try-catch
Validate before calling
// Check badger dir integrity and exclusive access before upgrade
flock := filepath.Join(pDir, "LOCK")
if _, err := os.Stat(pDir); err != nil { log.Fatalf("missing p dir: %v", err) }
_ = flock // ensure no live dgraph holds this dir
Type guard
func isDropDepreciatedErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "Error while dropping depreciated preds/types.")
} Try / catch
if err := upgrade.OfflineUpgradeFrom2011To2103(db); err != nil {
log.Fatalf("drop depreciated step failed: %+v", err)
} Prevention
- Run the upgrade exclusively — no concurrent dgraph on the same p directory
- Verify disk health/space with df and badger debug tooling
- Re-restore from backup if entries are corrupt
- Keep the original backup file until the upgrade is validated
When it happens
Trigger: Running OfflineUpgradeFrom2011To2103 where dropDepreciated fails to delete deprecated predicate/type entries from the badger DB (e.g. badger transaction or iteration error, DB closed, disk failure).
Common situations: Migrating a 20.11 backup to 21.03; corrupted p directory; badger write errors due to full disk or I/O errors during the offline upgrade.
Related errors
- Error while updating GraphQL schema.
- while updating persisted query's type
- while upgrading persisted query
- while upgrading cors
- while updating persisted query's schema
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/175e691bb6072d15.
Report an issue: GitHub.