{"record":{"id":"063f8faff4be5104","repo":"dgraph-io/dgraph","slug":"p-directory-does-not-exist-for-group-d-s","errorCode":null,"errorMessage":"p directory does not exist for group [%d]: [%s]","messagePattern":"p directory does not exist for group \\[(.+?)\\]: \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/dgraphimport/import_client.go","lineNumber":120,"sourceCode":"\t\t\treturn nil, ctx.Err()\n\t\tcase <-time.After(retryDelay):\n\t\t}\n\t\tretryDelay = min(retryDelay*2, 10*time.Second)\n\t}\n}\n\n// streamSnapshot takes a p directory and a set of group IDs and streams the data from the\n// p directory to the corresponding group IDs. It first scans the provided directory for\n// subdirectories named with numeric group IDs.\nfunc streamSnapshot(ctx context.Context, dc api.DgraphClient, baseDir string, groups []uint32) error {\n\tglog.Infof(\"[import] Starting to stream snapshot from directory: %s\", baseDir)\n\n\terrG, errGrpCtx := errgroup.WithContext(ctx)\n\tfor _, group := range groups {\n\t\terrG.Go(func() error {\n\t\t\tpDir := filepath.Join(baseDir, fmt.Sprintf(\"%d\", group-1), \"p\")\n\t\t\tif _, err := os.Stat(pDir); err != nil {\n\t\t\t\treturn fmt.Errorf(\"p directory does not exist for group [%d]: [%s]\", group, pDir)\n\t\t\t}\n\t\t\tglog.Infof(\"[import] Streaming data for group [%d] from directory: [%s]\", group, pDir)\n\t\t\tif err := streamSnapshotForGroup(errGrpCtx, dc, pDir, group); err != nil {\n\t\t\t\tglog.Errorf(\"[import] Failed to stream data for group [%v] from directory: [%s]: %v\", group, pDir, err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn nil\n\t\t})\n\t}\n\n\tif err := errG.Wait(); err != nil {\n\t\tglog.Errorf(\"[import] failed to stream external snapshot: %v\", err)\n\t\t// If errors occurs during streaming of the external snapshot, we drop all the data and\n\t\t// go back to ensure a clean slate and the cluster remains in working state.\n\t\tglog.Info(\"[import] dropping all the data and going back to clean slate\")\n\t\treq := &api.UpdateExtSnapshotStreamingStateRequest{\n\t\t\tStart:    false,","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/dgraphimport/import_client.go#L102-L138","documentation":"While streaming the snapshot, streamSnapshot expects baseDir to contain a numeric subdirectory per group (group-1) with a p/ inside (bulk output layout). os.Stat failing means that expected p directory is missing, so data for that group cannot be streamed.","triggerScenarios":"The bulkOutDir passed to Import does not follow the dgraph bulk output layout — missing <N>/p subdirectory for one of the groups reported by the snapshot initiation response.","commonSituations":"Pointing at the wrong (parent or partial) directory, bulk output moved/trimmed (p dirs deleted to save space), group count from the cluster larger than the number of exported shards, path typos or volume not mounted.","solutions":["Verify the layout: bulkOutDir must contain directories 0/p, 1/p, ... for each group id returned in resp.Groups.","Re-run `dgraph bulk` if the p directories were deleted or the export is incomplete; point bulkOutDir at its output root.","Confirm the volume/mount holding the bulk output is attached and paths are absolute/correct.","Match group count: if the cluster has more groups than exported shards, produce bulk output for all groups or stream only exported ones."],"exampleFix":"// before\nerr := dgraphimport.Import(ctx, addr, \"/data/bulk_output/shards\") // wrong level: p dirs live in 0/p, 1/p\n// after\nerr := dgraphimport.Import(ctx, addr, \"/data/bulk_output\")       // root containing <group-1>/p","handlingStrategy":"validation","validationCode":"if err := validateBulkLayout(bulkDir, groups); err != nil { return err }\n\nfunc validateBulkLayout(base string, groups []uint32) error {\n    for _, g := range groups {\n        p := filepath.Join(base, fmt.Sprintf(\"%d\", g-1), \"p\")\n        if _, err := os.Stat(p); err != nil {\n            return fmt.Errorf(\"missing %s for group %d\", p, g)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := dgraphimport.Import(ctx, addr, bulkDir); err != nil {\n    if strings.Contains(err.Error(), \"p directory does not exist\") {\n        return fmt.Errorf(\"bulk output layout mismatch: expected <root>/<group-1>/p; got root %q\", bulkDir)\n    }\n    return err\n}","preventionTips":["Always pass the ROOT of the bulk output (parent of the numeric dirs), not a shard subdir.","Preserve the full bulk output tree (0/p, 1/p, ...) until import completes.","Ensure the cluster's group count matches the bulk export's shard count.","Verify mounts/paths on the node running the import."],"tags":["filesystem","path","bulk-loader","import"],"backgroundTag":"missing-required-path","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}