{"record":{"id":"8de49fdb660628b5","repo":"dgraph-io/dgraph","slug":"server-is-not-leader-of-this-group","errorCode":null,"errorMessage":"Server is not leader of this group","messagePattern":"Server is not leader of this group","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/predicate_move.go","lineNumber":36,"sourceCode":"\t\"github.com/pkg/errors\"\n\t\"go.opentelemetry.io/otel/attribute\"\n\t\"go.opentelemetry.io/otel/trace\"\n\t\"google.golang.org/protobuf/proto\"\n\n\t\"github.com/dgraph-io/badger/v4\"\n\tbpb \"github.com/dgraph-io/badger/v4/pb\"\n\t\"github.com/dgraph-io/dgo/v250/protos/api\"\n\t\"github.com/dgraph-io/dgraph/v25/posting\"\n\t\"github.com/dgraph-io/dgraph/v25/protos/pb\"\n\t\"github.com/dgraph-io/dgraph/v25/schema\"\n\t\"github.com/dgraph-io/dgraph/v25/tok/hnsw\"\n\t\"github.com/dgraph-io/dgraph/v25/x\"\n\t\"github.com/dgraph-io/ristretto/v2/z\"\n)\n\nvar (\n\terrEmptyPredicate = errors.Errorf(\"Predicate not specified\")\n\terrNotLeader      = errors.Errorf(\"Server is not leader of this group\")\n\temptyPayload      = api.Payload{}\n)\n\n// size of kvs won't be too big, we would take care before proposing.\nfunc populateKeyValues(ctx context.Context, kvs []*bpb.KV) error {\n\tglog.Infof(\"Writing %d keys\\n\", len(kvs))\n\tif len(kvs) == 0 {\n\t\treturn nil\n\t}\n\twriter := posting.NewTxnWriter(pstore)\n\tif err := writer.Write(&bpb.KVList{Kv: kvs}); err != nil {\n\t\treturn err\n\t}\n\tif err := writer.Flush(); err != nil {\n\t\treturn err\n\t}\n\tpk, err := x.Parse(kvs[0].Key)\n\tif err != nil {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/predicate_move.go#L18-L54","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the operation — Zero automatically retries moves once the new leader is elected.","Check `dgraph debug`/metrics or logs to confirm which Alpha is the current leader and that Raft quorum exists.","If leadership is flapping, investigate network connectivity and disk latency between Alpha members.","Ensure Zero can reach the group's leader (correct gRPC addresses in the membership list)."],"exampleFix":"// before: fixed address pointing at follower\nconn = dial(\"alpha-2:7080\")\n// after: resolve leader via Zero membership before moving\nleader := groups.LeaderOfGroup(gid)\nconn = dial(leader.Addr)","handlingStrategy":"retry","validationCode":"leader := zeroClient.LeaderOfGroup(groupId)\nif leader == nil || leader.Addr != targetAlphaAddr {\n\treturn fmt.Errorf(\"target %s is not leader of group %d\", targetAlphaAddr, groupId)\n}","typeGuard":null,"tryCatchPattern":"err := worker.MovePredicate(ctx, pred, src, dst)\nif err != nil && errors.Is(err, worker.ErrNotLeader) {\n\ttime.Sleep(2 * time.Second) // wait for election, then retry\n}","preventionTips":["Resolve the current leader via Zero before issuing internal move calls","Retry with backoff — Zero re-issues moves after elections","Investigate flapping leadership (network, disk latency) before moving tablets","Move predicates only when the cluster is quiescent and healthy"],"tags":["dgraph","leader-election","raft","predicate-move"],"backgroundTag":"not-group-leader","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}