dgraph-io/dgraph · error
Upsert Predicate feature is not supported for loadinginto mu
Error message
Upsert Predicate feature is not supported for loadinginto multiple namespaces.
What it means
The live loader rejects combining --upsert-predicate with a load that targets multiple (or root-namespace-wide) namespaces. Upsert predicate tracking keeps a single per-predicate index of mutation keys, which is not namespace-aware for multi-namespace loads, so enabling both would corrupt the upsert index. The loader errors out early before processing any files.
Source
Thrown at dgraph/cmd/live/run.go:728
}
}()
ctx := context.Background()
// singleNsOp is set to false, when loading data into a namespace different from the one user
// provided credentials for.
singleNsOp := true
if len(creds.GetString("user")) > 0 && creds.GetUint64("namespace") == x.RootNamespace &&
opt.namespaceToLoad != x.RootNamespace {
singleNsOp = false
}
rootNsOperation := false
if !singleNsOp {
// Attach the root namespace to the context to specify that the query/mutations with this context
// will be root namespace wide.
rootNsOperation = true
ctx = x.AttachRootNsOperation(ctx, opt.namespaceToLoad)
// We don't support upsert predicate while loading data in multiple namespace.
if len(opt.upsertPredicate) > 0 {
return errors.Errorf("Upsert Predicate feature is not supported for loading" +
"into multiple namespaces.")
}
}
bmOpts := batchMutationOptions{
Size: opt.batchSize,
Pending: opt.concurrent,
PrintCounters: true,
Ctx: ctx,
MaxRetries: math.MaxUint32,
bufferSize: opt.bufferSize,
}
// Create directory for temporary buffers.
x.Check(os.MkdirAll(opt.tmpDir, 0700))
dg, closeFunc := x.GetDgraphClient(Live.Conf, true)
defer closeFunc()View on GitHub (pinned to 759e242be6)
Solutions
- Drop the --upsert-predicate flag when loading into multiple namespaces
- Load each namespace separately with --force-namespace and --upsert-predicate in separate runs
- If upsert predicates are needed, restructure data files so one run handles exactly one namespace
Example fix
// before dgraph live --upsert-predicate "dgraph.type" -f multi-ns.rdf --preserve-ns // after dgraph live --upsert-predicate "dgraph.type" --force-namespace 0x1 -f ns1.rdf dgraph live --upsert-predicate "dgraph.type" --force-namespace 0x2 -f ns2.rdf
Defensive patterns
Strategy: validation
Validate before calling
// Reject incompatible flag combos before invoking the CLI
if (opts.upsertPredicate && (opts.preserveNs || opts.forceNamespace === undefined && opts.multiNamespace)) {
throw new Error('--upsert-predicate cannot be combined with multi-namespace loads');
} Type guard
function isSingleNamespaceLoad(opts) {
return !opts.preserveNs && Number.isFinite(opts.forceNamespace);
} Try / catch
try {
await runLive(args);
} catch (e) {
if (String(e.message).includes('Upsert Predicate feature is not supported')) {
console.error('Remove --upsert-predicate or split the load per namespace');
} else { throw e; }
} Prevention
- Document flag incompatibilities in load scripts
- Validate CLI flag combinations in wrapper scripts before execution
- Load one namespace per invocation when upsert predicates are needed
When it happens
Trigger: Running `dgraph live` with both `--upsert-predicate <pred>` set and multi-namespace mode active — i.e. no --force-namespace / preserve-ns scenario where opt.namespaceToLoad spans all namespaces (rootNsOperation true).
Common situations: Bulk-loading a dump that contains many namespaces while also wanting upsert-predicate bookkeeping; scripts written for single-namespace loads reused against multi-namespace data files.
Related errors
- cannot force namespace %#x when provided creds are not of su
- Cannot load into namespace %#x. It does not exist.
- Key size value is too large (x > 4096)
- Key size value must be a factor of 2
- Elliptic curve value must be one of: P224, P256, P384 or P52
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/7d1cc4f2b4931b32.
Report an issue: GitHub.