{"record":{"id":"3b4b104d77941ff1","repo":"dgraph-io/dgraph","slug":"failed-to-send-request-for-group-id-v-to-the-se","errorCode":null,"errorMessage":"failed to send request for group ID [%v] to the server: %w","messagePattern":"failed to send request for group ID \\[(.+?)\\] to the server: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/dgraphimport/import_client.go","lineNumber":196,"sourceCode":"\t// Open the BadgerDB instance at the specified directory\n\topt := badger.DefaultOptions(pdir)\n\topt.ReadOnly = true\n\tps, err := badger.OpenManaged(opt)\n\tif err != nil {\n\t\tglog.Errorf(\"failed to open BadgerDB at [%s]: %v\", pdir, err)\n\t\treturn fmt.Errorf(\"failed to open BadgerDB at [%v]: %v\", pdir, err)\n\t}\n\tdefer func() {\n\t\tif err := ps.Close(); err != nil {\n\t\t\tglog.Warningf(\"[import] Error closing BadgerDB: %v\", err)\n\t\t}\n\t}()\n\n\t// Send group ID as the first message in the stream\n\tglog.Infof(\"[import] Sending request for streaming external snapshot for group ID [%v]\", groupId)\n\tgroupReq := &api.StreamExtSnapshotRequest{GroupId: groupId}\n\tif err := out.Send(groupReq); err != nil {\n\t\treturn fmt.Errorf(\"failed to send request for group ID [%v] to the server: %w\", groupId, err)\n\t}\n\tif _, err := out.Recv(); err != nil {\n\t\treturn fmt.Errorf(\"failed to receive response for group ID [%v] from the server: %w\", groupId, err)\n\t}\n\n\tglog.Infof(\"[import] Group [%v]: Received ACK for sending group request\", groupId)\n\n\t// Configure and start the BadgerDB stream\n\tglog.Infof(\"[import] Starting BadgerDB stream for group [%v]\", groupId)\n\tif err := streamBadger(ctx, ps, out, groupId); err != nil {\n\t\treturn fmt.Errorf(\"badger streaming failed for group [%v]: %v\", groupId, err)\n\t}\n\treturn nil\n}\n\n// streamBadger runs a BadgerDB stream to send key-value pairs to the specified group.\n// It creates a new stream at the maximum sequence number and sends the data to the specified group.\n// It also sends a final 'done' signal to mark completion.","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/dgraphimport/import_client.go#L178-L214","documentation":"Returned when out.Send of the first StreamExtSnapshotRequest (carrying only the GroupId) fails on the open stream. The server expects the group ID as the first message; a send failure means the stream is broken before any data flows.","triggerScenarios":"The gRPC stream was closed by the server right after setup (server-side error, load balancer idle timeout, Alpha crash); context cancelled mid-send; sending on a stream the server already rejected (e.g. unknown group).","commonSituations":"Long-lived stream killed by an intermediate proxy/LB idle timeout; Alpha draining or restarting between stream open and first send; cluster reconfiguration changed group membership so the group ID is rejected.","solutions":["Check the wrapped gRPC error/status for the root cause (Unavailable, Canceled, Internal).","Confirm the group ID exists in the current cluster (dgraph status / raft state).","Disable LB idle-timeout killing of long gRPC streams or add keepalive settings.","Retry the whole streamSnapshotForGroup; streams are not resumable.","Verify the Alpha is healthy and not restarting during the import."],"exampleFix":"// before\nif err := out.Send(groupReq); err != nil {\n\treturn fmt.Errorf(\"failed to send request for group ID [%v] to the server: %w\", groupId, err)\n}\n// after\nif err := out.Send(groupReq); err != nil {\n\tif errors.Is(err, io.EOF) {\n\t\treturn fmt.Errorf(\"server closed stream for group %d before handshake; check server logs and group membership\", groupId)\n\t}\n\treturn fmt.Errorf(\"failed to send request for group ID [%v] to the server: %w\", groupId, err)\n}","handlingStrategy":"try-catch","validationCode":"if ctx.Err() != nil {\n\treturn fmt.Errorf(\"context already cancelled before stream handshake: %w\", ctx.Err())\n}","typeGuard":"func isEOFOrBrokenStream(err error) bool {\n\treturn errors.Is(err, io.EOF) ||\n\t\t(errors.Is(err, context.Canceled)) ||\n\t\t(func() bool { s, ok := status.FromError(err); return ok && s.Code() == codes.Unavailable }())\n}","tryCatchPattern":"if err := out.Send(groupReq); err != nil {\n\tif isEOFOrBrokenStream(err) {\n\t\t// stream died before handshake: rebuild stream and retry once\n\t\treturn retryStreamSnapshotForGroup(ctx, dc, pdir, groupId)\n\t}\n\treturn fmt.Errorf(\"failed to send request for group ID [%v] to the server: %w\", groupId, err)\n}","preventionTips":["Add gRPC keepalive so idle streams are not reaped by LBs.","Avoid proxies between importer and Alpha for long streams.","Validate group IDs against current cluster membership before import.","Don't cancel the context between stream open and the first send."],"tags":["grpc","network","stream","snapshot-import"],"backgroundTag":"grpc-send-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}