dgraph-io/dgraph · error

Server is not leader of this group

Error message

Server is not leader of this group

What it means

errNotLeader is returned by Oracle, MoveTablet, and MovePredicate in the worker package when the receiving Alpha is not the leader of the group that owns the predicate. Predicate moves must be coordinated by the group's leader; followers reject the request outright.

Source

Thrown at worker/predicate_move.go:36

	"github.com/pkg/errors"
	"go.opentelemetry.io/otel/attribute"
	"go.opentelemetry.io/otel/trace"
	"google.golang.org/protobuf/proto"

	"github.com/dgraph-io/badger/v4"
	bpb "github.com/dgraph-io/badger/v4/pb"
	"github.com/dgraph-io/dgo/v250/protos/api"
	"github.com/dgraph-io/dgraph/v25/posting"
	"github.com/dgraph-io/dgraph/v25/protos/pb"
	"github.com/dgraph-io/dgraph/v25/schema"
	"github.com/dgraph-io/dgraph/v25/tok/hnsw"
	"github.com/dgraph-io/dgraph/v25/x"
	"github.com/dgraph-io/ristretto/v2/z"
)

var (
	errEmptyPredicate = errors.Errorf("Predicate not specified")
	errNotLeader      = errors.Errorf("Server is not leader of this group")
	emptyPayload      = api.Payload{}
)

// size of kvs won't be too big, we would take care before proposing.
func populateKeyValues(ctx context.Context, kvs []*bpb.KV) error {
	glog.Infof("Writing %d keys\n", len(kvs))
	if len(kvs) == 0 {
		return nil
	}
	writer := posting.NewTxnWriter(pstore)
	if err := writer.Write(&bpb.KVList{Kv: kvs}); err != nil {
		return err
	}
	if err := writer.Flush(); err != nil {
		return err
	}
	pk, err := x.Parse(kvs[0].Key)
	if err != nil {

View on GitHub (pinned to 759e242be6)

Solutions

  1. Retry the operation — Zero automatically retries moves once the new leader is elected.
  2. Check `dgraph debug`/metrics or logs to confirm which Alpha is the current leader and that Raft quorum exists.
  3. If leadership is flapping, investigate network connectivity and disk latency between Alpha members.
  4. Ensure Zero can reach the group's leader (correct gRPC addresses in the membership list).

Example fix

// before: fixed address pointing at follower
conn = dial("alpha-2:7080")
// after: resolve leader via Zero membership before moving
leader := groups.LeaderOfGroup(gid)
conn = dial(leader.Addr)
Defensive patterns

Strategy: retry

Validate before calling

leader := zeroClient.LeaderOfGroup(groupId)
if leader == nil || leader.Addr != targetAlphaAddr {
	return fmt.Errorf("target %s is not leader of group %d", targetAlphaAddr, groupId)
}

Try / catch

err := worker.MovePredicate(ctx, pred, src, dst)
if err != nil && errors.Is(err, worker.ErrNotLeader) {
	time.Sleep(2 * time.Second) // wait for election, then retry
}

Prevention

When it happens

Trigger: Calling MovePredicate/MoveTablet (e.g. Zero-initiated rebalancing) against an Alpha whose group leader changed (leader election in progress, network partition) or because the client explicitly targeted a non-leader node.

Common situations: Zero fires a movePredicates call right when leadership flips after a crash or restart; network flakiness causes the leader to step down mid-move; manually pointing internal move calls at a follower.

Related errors


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