{"record":{"id":"a1b3bcc0b8987088","repo":"dgraph-io/dgraph","slug":"map-phase-failed-to-ban-namespace-d","errorCode":null,"errorMessage":"Map phase failed to ban namespace: %d","messagePattern":"Map phase failed to ban namespace: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/restore_map.go","lineNumber":889,"sourceCode":"\t\t\t\tns, err := strconv.ParseUint(op.DropValue, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrap(err, \"map phase failed to parse namespace\")\n\t\t\t\t}\n\t\t\t\tdropNs[ns] = struct{}{}\n\t\t\tcase pb.DropOperation_ATTR:\n\t\t\t\tdropAttr[op.DropValue] = struct{}{}\n\t\t\tcase pb.DropOperation_NS:\n\t\t\t\t// pstore will be nil for export_backup tool. In that case we don't need to ban ns.\n\t\t\t\tif pstore == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// If there is a drop namespace, we just ban the namespace in the pstore.\n\t\t\t\tns, err := strconv.ParseUint(op.DropValue, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrapf(err, \"Map phase failed to parse namespace\")\n\t\t\t\t}\n\t\t\t\tif err := pstore.BanNamespace(ns); err != nil {\n\t\t\t\t\treturn nil, errors.Wrapf(err, \"Map phase failed to ban namespace: %d\", ns)\n\t\t\t\t}\n\t\t\t\tmaxBannedNs = x.Max(maxBannedNs, ns)\n\t\t\t}\n\t\t}\n\t\tglog.Infof(\"[MAP] Processed manifest num: %v\", manifest.BackupNum)\n\t} // done with all the manifests.\n\n\tglog.Infof(\"Histogram of map input sizes:\\n%s\\n\", mapper.szHist)\n\tclose(mapper.reqCh)\n\tif err := g.Wait(); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"from processKVList\")\n\t}\n\tif err := mapper.Flush(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to flush the mapper\")\n\t}\n\tmapRes := &mapResult{\n\t\tmaxUid:        mapper.maxUid,\n\t\tmaxNs:         mapper.maxNs,","sourceCodeStart":871,"sourceCodeEnd":907,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/restore_map.go#L871-L907","documentation":"During the map phase of a restore/export, when the backup manifest contains a drop-namespace operation, RunMapper tries to ban that namespace in the posting store via pstore.BanNamespace. This error wraps any failure from that call (e.g. the store rejected the ban) and includes the namespace ID being banned.","triggerScenarios":"RunMapper processes a manifest with DropValue set to a namespace ID; strconv.ParseUint succeeds but pstore.BanNamespace(ns) returns an error (internal posting-store failure writing the ban key).","commonSituations":"Offline restores or export-based backups where the underlying posting store is unhealthy, read-only, or the ban key write fails mid-restore; corruption or network issues to the Badger/pstore backend.","solutions":["Inspect the wrapped root cause error (errors.Wrapf preserves it) and fix the underlying pstore failure","Verify the posting store (Badger) directories are writable and healthy on this Alpha","Retry the restore once the store is healthy; the ban is idempotent per namespace","Check disk space and file permissions on the node running RunMapper"],"exampleFix":"// before\nif err := pstore.BanNamespace(ns); err != nil {\n    return nil, errors.Wrapf(err, \"Map phase failed to ban namespace: %d\", ns)\n}\n// after\nif err := pstore.BanNamespace(ns); err != nil {\n    glog.Errorf(\"ban namespace %d failed: %v; check pstore health\", ns, err)\n    return nil, errors.Wrapf(err, \"Map phase failed to ban namespace: %d\", ns)\n}","handlingStrategy":"try-catch","validationCode":"if err := validatePstoreWritable(); err != nil { return fmt.Errorf(\"pstore not writable before restore: %w\", err) }","typeGuard":null,"tryCatchPattern":"res, err := RunMapper(ctx, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to ban namespace\") {\n        // check pstore health/disk, then retry restore\n        return retryRestore(opts)\n    }\n    return err\n}","preventionTips":["Check pstore/Badger directory writability and disk space before starting a restore","Monitor disk and IO health on Alpha nodes","Log the namespace ID and root cause chain for diagnosis"],"tags":["restore","namespace","pstore","backup"],"backgroundTag":"namespace-ban-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}