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

  1. Drop the --upsert-predicate flag when loading into multiple namespaces
  2. Load each namespace separately with --force-namespace and --upsert-predicate in separate runs
  3. 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

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


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