dgraph-io/dgraph · error

Map phase failed to parse namespace

Error message

Map phase failed to parse namespace

What it means

In the second (post-map) pass over DropOperations, NS drops are applied to pstore via BanNamespace. RunMapper parses op.DropValue again with strconv.ParseUint and wraps parse failures as 'Map phase failed to parse namespace' (capital M), then also wraps any pstore.BanNamespace failure with the same prefix plus the ns id.

Source

Thrown at worker/restore_map.go:886

					dropAll = true
					continue
				}
				ns, err := strconv.ParseUint(op.DropValue, 0, 64)
				if err != nil {
					return nil, errors.Wrap(err, "map phase failed to parse namespace")
				}
				dropNs[ns] = struct{}{}
			case pb.DropOperation_ATTR:
				dropAttr[op.DropValue] = struct{}{}
			case pb.DropOperation_NS:
				// pstore will be nil for export_backup tool. In that case we don't need to ban ns.
				if pstore == nil {
					continue
				}
				// If there is a drop namespace, we just ban the namespace in the pstore.
				ns, err := strconv.ParseUint(op.DropValue, 0, 64)
				if err != nil {
					return nil, errors.Wrapf(err, "Map phase failed to parse namespace")
				}
				if err := pstore.BanNamespace(ns); err != nil {
					return nil, errors.Wrapf(err, "Map phase failed to ban namespace: %d", ns)
				}
				maxBannedNs = x.Max(maxBannedNs, ns)
			}
		}
		glog.Infof("[MAP] Processed manifest num: %v", manifest.BackupNum)
	} // done with all the manifests.

	glog.Infof("Histogram of map input sizes:\n%s\n", mapper.szHist)
	close(mapper.reqCh)
	if err := g.Wait(); err != nil {
		return nil, errors.Wrapf(err, "from processKVList")
	}
	if err := mapper.Flush(); err != nil {
		return nil, errors.Wrap(err, "failed to flush the mapper")
	}

View on GitHub (pinned to 759e242be6)

Solutions

  1. Check the wrapped cause: a strconv error means the manifest NS DropValue is malformed — fix the manifest or restore with the matching Dgraph version.
  2. A BanNamespace failure (message includes the ns id) indicates a badger/pstore problem — check disk health and that the store is open and writable.
  3. Validate all DropOperations entries in the manifest are well-formed before starting the restore.
  4. Re-take or repair the backup if its manifests are corrupt.
Defensive patterns

Strategy: validation

Validate before calling

for _, op := range manifest.DropOperations {
    if op.DropOp == pb.DropOperation_NS {
        if _, err := strconv.ParseUint(op.DropValue, 0, 64); err != nil {
            return fmt.Errorf("invalid NS DropValue %q in manifest", op.DropValue)
        }
    }
}

Prevention

When it happens

Trigger: While applying NS drop operations when pstore != nil (restore into a live Dgraph, not export_backup), op.DropValue for a DropOp_NS entry is not a valid uint64, or BanNamespace itself fails on the badger store.

Common situations: Same manifest format mismatch/corruption as error 958 but hit in the pstore-application path; badger write failure or store closed when banning the namespace during restore into an Alpha/post-restore processor.

Understand the failure class

Related errors


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