{"record":{"id":"f67b87bcc0f08087","repo":"dgraph-io/dgraph","slug":"unable-to-reach-leader-of-group-d","errorCode":null,"errorMessage":"Unable to reach leader of group: %d","messagePattern":"Unable to reach leader of group: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/zero/zero.go","lineNumber":815,"sourceCode":"\tfor _, tablet := range group.Tablets {\n\t\tgid = tablet.GroupId\n\t\tbreak\n\t}\n\tif gid == 0 {\n\t\treturn errors.Errorf(\"Unable to find group\")\n\t}\n\tstate, err := s.latestMembershipState(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsg, ok := state.Groups[gid]\n\tif !ok {\n\t\treturn errors.Errorf(\"Unable to find group: %d\", gid)\n\t}\n\n\tpl := s.Leader(gid)\n\tif pl == nil {\n\t\treturn errors.Errorf(\"Unable to reach leader of group: %d\", gid)\n\t}\n\twc := pb.NewWorkerClient(pl.Get())\n\n\tfor pred := range group.Tablets {\n\t\tif _, found := sg.Tablets[pred]; found {\n\t\t\tcontinue\n\t\t}\n\t\tglog.Infof(\"Tablet: %v does not belong to group: %d. Sending delete instruction.\",\n\t\t\tpred, gid)\n\t\tin := &pb.MovePredicatePayload{\n\t\t\tPredicate: pred,\n\t\t\tSourceGid: gid,\n\t\t\tDestGid:   0,\n\t\t}\n\t\tif _, err := wc.MovePredicate(ctx, in); err != nil {\n\t\t\treturn err\n\t\t}\n\t}","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/zero/zero.go#L797-L833","documentation":"Zero cannot obtain a gRPC connection to the RAFT leader of the given group while executing predicate deletion. The group exists in the membership state but s.Leader(gid) returned nil, meaning no healthy leader address is known to Zero (leader down, not yet elected, or membership maps out of sync). deletePredicates aborts and the caller only logs a warning, so cleanup is skipped.","triggerScenarios":"A drop of a predicate triggers MovePredicate cleanup via UpdateMembership; Zero knows the group/tablets from a stale membership snapshot but the leader of that group has crashed, been restarted, or has not yet been elected when deletePredicates calls s.Leader(gid).","commonSituations":"Alpha process in the group crashed or is restarting during a schema drop; network partition between Zero and the group's Alphas; a single-node group whose member is down; dropping predicates right after resizing a cluster.","solutions":["Verify all Alphas of the group are running and connected to Zero (check /health and Zero's /state endpoint).","Retry the predicate drop after the group elects a leader; the error is transient during elections.","Check network/firewall connectivity between Zero and the Alpha servers on their gRPC ports.","If the group should no longer exist (removed Alphas), wait for Zero's membership state to converge or use cleanupTool/dgraph zero removal for dead nodes."],"exampleFix":"// before\ncurl -X POST localhost:8080/admin -d '{\"query\":\"mutation { dropOp(pattern: \"name\") { response { message } } }\"}'  # fails while group leader is down\n// after\n# restart the down Alpha first, confirm leader in Zero /state, then re-run the drop","handlingStrategy":"retry","validationCode":"// Before dropping predicates, check Zero's membership state\nconst res = await fetch('http://zero:6080/state');\nconst state = await res.json();\nconst group = state.groups && state.groups[gid];\nif (!group || !group.members || !group.members.some(m => m.leader && m.healthy === true)) {\n  throw new Error(`Group ${gid} has no healthy leader; defer predicate drop`);\n}","typeGuard":"function hasHealthyLeader(group) {\n  return Boolean(group && Array.isArray(group.members) &&\n    group.members.some(m => m.leader === true && m.healthy === true));\n}","tryCatchPattern":"try {\n  await dropPredicate(pattern);\n} catch (err) {\n  if (/Unable to reach leader of group/.test(String(err))) {\n    await waitForGroupLeader(gid);   // poll /state until leader healthy\n    await dropPredicate(pattern);    // retry once leader is up\n  } else {\n    throw err;\n  }\n}","preventionTips":["Monitor Alpha health and RAFT leader status before issuing drops","Avoid dropping predicates during cluster maintenance, restarts, or elections","Alert on Zero/Alpha connectivity loss so cleanup windows are chosen deliberately","Keep an odd number of Alpha replicas per group so a leader always exists"],"tags":["dgraph","zero","cluster","raft-leader","predicate-drop"],"backgroundTag":"raft-leader-unavailable","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}