{"record":{"id":"7ea72ca016a78eca","repo":"dgraph-io/dgraph","slug":"unable-to-connect-to-the-leader-of-group-v-v","errorCode":null,"errorMessage":"unable to connect to the leader of group [%v] : %v","messagePattern":"unable to connect to the leader of group \\[(.+?)\\] : (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/import.go","lineNumber":370,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to receive initial stream message: %v\", err)\n\t}\n\n\tif err := stream.Send(&api.StreamExtSnapshotResponse{Finish: false}); err != nil {\n\t\treturn fmt.Errorf(\"failed to send initial response: %v\", err)\n\t}\n\n\tgroupId := req.GroupId\n\tif groupId == groups().Node.gid {\n\t\tglog.Infof(\"[import] streaming external snapshot to current group [%v]\", groupId)\n\t\treturn streamInGroup(stream, true)\n\t}\n\n\tglog.Infof(\"[import] streaming external snapshot to other group [%v]\", groupId)\n\tpl := groups().Leader(groupId)\n\tif pl == nil {\n\t\tglog.Errorf(\"[import] unable to connect to the leader of group [%v]\", groupId)\n\t\treturn fmt.Errorf(\"unable to connect to the leader of group [%v] : %v\", groupId, conn.ErrNoConnection)\n\t}\n\n\tcon := pl.Get()\n\tc := pb.NewWorkerClient(con)\n\talphaStream, err := c.StreamExtSnapshot(stream.Context())\n\tif err != nil {\n\t\tglog.Errorf(\"[import] failed to establish stream with leader: %v\", err)\n\t\treturn fmt.Errorf(\"failed to establish stream with leader: %v\", err)\n\t}\n\tglog.Infof(\"[import] [forward %d -> %d] start\", groups().Node.gid, groupId)\n\tglog.Infof(\"[import] [forward %v -> %d] start\", groups().Node.MyAddr, groups().Leader(groupId).Addr)\n\n\tglog.Infof(\"[import] sending forward true to leader of group [%v]\", groupId)\n\tforwardReq := &api.StreamExtSnapshotRequest{Forward: true}\n\tif err := alphaStream.Send(forwardReq); err != nil {\n\t\tglog.Errorf(\"[import] failed to send forward request: %v\", err)\n\t\treturn fmt.Errorf(\"failed to send forward request: %v\", err)\n\t}","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/import.go#L352-L388","documentation":"InStream is the server side of the StreamExtSnapshot import RPC. Before it can forward snapshot data it resolves the leader of the target group via groups().Leader(groupId); if no leader is reachable (nil) the operation cannot proceed and it returns this error wrapping conn.ErrNoConnection. It means this node knows of the group but has no healthy gRPC connection to its leader.","triggerScenarios":"groups().Leader(groupId) returns nil because the target group's leader is down, the membership/raft state has not converged yet, or groupId refers to a group that has no tablets/leader in this cluster.","commonSituations":"Import started immediately after cluster restart before Raft elections complete; leader of target group crashed mid-import; firewall blocks the internal gRPC port so the pool has no healthy connection; typos or stale groupId from an older snapshot manifest.","solutions":["Verify the leader of the target group exists and is healthy (dgraph group/health endpoints or logs showing a leader elected for that group)","Wait for membership/raft to converge after restart, then retry the import","Check network connectivity and the internal port (default 7080) between the importing node and the target leader","Confirm groupId matches a group that actually holds data in this cluster","Retry the whole StreamExtSnapshot import once the cluster is healthy"],"exampleFix":"// before\npl := groups().Leader(groupId)\nif pl == nil {\n    return fmt.Errorf(\"unable to connect to the leader of group [%v] : %v\", groupId, conn.ErrNoConnection)\n}\n// after: add bounded retry to ride out election lag\nvar pl *conn.Node\nfor i := 0; i < 10 && pl == nil; i++ {\n    pl = groups().Leader(groupId)\n    if pl == nil {\n        time.Sleep(2 * time.Second)\n    }\n}\nif pl == nil {\n    return fmt.Errorf(\"unable to connect to the leader of group [%v] : %v\", groupId, conn.ErrNoConnection)\n}","handlingStrategy":"retry","validationCode":"// client-side precheck before starting the import\nleader, err := dc.CheckDgraphLeader(groupID) // query /health or /state for a leader in the target group\nif err != nil || leader == nil {\n    return fmt.Errorf(\"no healthy leader for group %v; aborting import\", groupID)\n}","typeGuard":"func hasLeader(gid uint32) bool {\n    n := groups().Leader(gid) // server-side guard used before dialing\n    return n != nil && n.Get() != nil\n}","tryCatchPattern":"err := runImport(ctx)\nif err != nil && strings.Contains(err.Error(), \"unable to connect to the leader\") {\n    // wait for raft elections, retry with backoff\n}","preventionTips":["Wait for all groups to report a leader before starting an import","Verify internal port (7080) reachability between all alphas","Pin imports to a stable, fully-replicated cluster","Retry imports with backoff after restarts"],"tags":["grpc","raft","cluster","import"],"backgroundTag":"no-group-leader","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}