{"record":{"id":"175e691bb6072d15","repo":"dgraph-io/dgraph","slug":"error-while-dropping-depreciated-preds-types","errorCode":null,"errorMessage":"Error while dropping depreciated preds/types.","messagePattern":"Error while dropping depreciated preds/types\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upgrade/change_v21.03.0.go","lineNumber":382,"sourceCode":"\t}\n\tfor typ := range deprecatedTypes {\n\t\tprefixes = append(prefixes, x.TypeKey(x.AttrInRootNamespace(typ)))\n\t}\n\treturn db.DropPrefix(prefixes...)\n}\n\n// fixCors removes the internal predicates from the restored backup. This also appends CORS from\n// dgraph.cors to GraphQL schema.\nfunc fixCors(db *badger.DB) error {\n\tglog.Infof(\"Fixing cors information in the restored backup.\")\n\tcors, err := getCors(db)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"Error while getting cors from db.\")\n\t}\n\tif err := updateGQLSchemaOffline(db, cors); err != nil {\n\t\treturn errors.Wrapf(err, \"Error while updating GraphQL schema.\")\n\t}\n\treturn errors.Wrapf(dropDepreciated(db), \"Error while dropping depreciated preds/types.\")\n}\n\n// fixPersistedQuery, for the schema related to persisted query removes the deprecated field from\n// the type and updates the index tokenizer for the predicate.\nfunc fixPersistedQuery(db *badger.DB) error {\n\tglog.Infof(\"Fixing persisted query schema in restored backup.\")\n\tupdate := func(entry *badger.Entry) error {\n\t\ttxn := db.NewTransactionAt(math.MaxUint64, true)\n\t\tdefer txn.Discard()\n\t\tif err := txn.SetEntry(entry); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Schema is written at version 1.\n\t\treturn txn.CommitAt(1, nil)\n\t}\n\n\t// Update the tokenizer in the schema.\n\tsu := pb.SchemaUpdate{","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/upgrade/change_v21.03.0.go#L364-L400","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\ndgraph upgrade offline -w v21.03.0 -d /var/lib/dgraph/p\n// after (ensure exclusive access and healthy disk)\nsystemctl stop dgraph\ndgraph debug --badgerdir /var/lib/dgraph/p  # verify integrity\ndgraph upgrade offline -w v21.03.0 -d /var/lib/dgraph/p","handlingStrategy":"try-catch","validationCode":"// Check badger dir integrity and exclusive access before upgrade\nflock := filepath.Join(pDir, \"LOCK\")\nif _, err := os.Stat(pDir); err != nil { log.Fatalf(\"missing p dir: %v\", err) }\n_ = flock // ensure no live dgraph holds this dir\n","typeGuard":"func isDropDepreciatedErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"Error while dropping depreciated preds/types.\")\n}","tryCatchPattern":"if err := upgrade.OfflineUpgradeFrom2011To2103(db); err != nil {\n\tlog.Fatalf(\"drop depreciated step failed: %+v\", err)\n}","preventionTips":["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"],"tags":["badger","migration","offline-upgrade","deprecated-predicates"],"backgroundTag":"offline-schema-upgrade-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}