{"record":{"id":"7d1cc4f2b4931b32","repo":"dgraph-io/dgraph","slug":"upsert-predicate-feature-is-not-supported-for-load","errorCode":null,"errorMessage":"Upsert Predicate feature is not supported for loadinginto multiple namespaces.","messagePattern":"Upsert Predicate feature is not supported for loadinginto multiple namespaces\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/live/run.go","lineNumber":728,"sourceCode":"\t\t}\n\t}()\n\tctx := context.Background()\n\t// singleNsOp is set to false, when loading data into a namespace different from the one user\n\t// provided credentials for.\n\tsingleNsOp := true\n\tif len(creds.GetString(\"user\")) > 0 && creds.GetUint64(\"namespace\") == x.RootNamespace &&\n\t\topt.namespaceToLoad != x.RootNamespace {\n\t\tsingleNsOp = false\n\t}\n\trootNsOperation := false\n\tif !singleNsOp {\n\t\t// Attach the root namespace to the context to specify that the query/mutations with this context\n\t\t// will be root namespace wide.\n\t\trootNsOperation = true\n\t\tctx = x.AttachRootNsOperation(ctx, opt.namespaceToLoad)\n\t\t// We don't support upsert predicate while loading data in multiple namespace.\n\t\tif len(opt.upsertPredicate) > 0 {\n\t\t\treturn errors.Errorf(\"Upsert Predicate feature is not supported for loading\" +\n\t\t\t\t\"into multiple namespaces.\")\n\t\t}\n\t}\n\n\tbmOpts := batchMutationOptions{\n\t\tSize:          opt.batchSize,\n\t\tPending:       opt.concurrent,\n\t\tPrintCounters: true,\n\t\tCtx:           ctx,\n\t\tMaxRetries:    math.MaxUint32,\n\t\tbufferSize:    opt.bufferSize,\n\t}\n\n\t// Create directory for temporary buffers.\n\tx.Check(os.MkdirAll(opt.tmpDir, 0700))\n\n\tdg, closeFunc := x.GetDgraphClient(Live.Conf, true)\n\tdefer closeFunc()","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/live/run.go#L710-L746","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\ndgraph live --upsert-predicate \"dgraph.type\" -f multi-ns.rdf --preserve-ns\n// after\ndgraph live --upsert-predicate \"dgraph.type\" --force-namespace 0x1 -f ns1.rdf\ndgraph live --upsert-predicate \"dgraph.type\" --force-namespace 0x2 -f ns2.rdf","handlingStrategy":"validation","validationCode":"// Reject incompatible flag combos before invoking the CLI\nif (opts.upsertPredicate && (opts.preserveNs || opts.forceNamespace === undefined && opts.multiNamespace)) {\n  throw new Error('--upsert-predicate cannot be combined with multi-namespace loads');\n}","typeGuard":"function isSingleNamespaceLoad(opts) {\n  return !opts.preserveNs && Number.isFinite(opts.forceNamespace);\n}","tryCatchPattern":"try {\n  await runLive(args);\n} catch (e) {\n  if (String(e.message).includes('Upsert Predicate feature is not supported')) {\n    console.error('Remove --upsert-predicate or split the load per namespace');\n  } else { throw e; }\n}","preventionTips":["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"],"tags":["cli","namespace","unsupported-feature","upsert"],"backgroundTag":"unsupported-feature-combination","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}