dgraph-io/dgraph · error
p directory does not exist for group [%d]: [%s]
Error message
p directory does not exist for group [%d]: [%s]
What it means
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.
Source
Thrown at dgraph/cmd/dgraphimport/import_client.go:120
return nil, ctx.Err()
case <-time.After(retryDelay):
}
retryDelay = min(retryDelay*2, 10*time.Second)
}
}
// streamSnapshot takes a p directory and a set of group IDs and streams the data from the
// p directory to the corresponding group IDs. It first scans the provided directory for
// subdirectories named with numeric group IDs.
func streamSnapshot(ctx context.Context, dc api.DgraphClient, baseDir string, groups []uint32) error {
glog.Infof("[import] Starting to stream snapshot from directory: %s", baseDir)
errG, errGrpCtx := errgroup.WithContext(ctx)
for _, group := range groups {
errG.Go(func() error {
pDir := filepath.Join(baseDir, fmt.Sprintf("%d", group-1), "p")
if _, err := os.Stat(pDir); err != nil {
return fmt.Errorf("p directory does not exist for group [%d]: [%s]", group, pDir)
}
glog.Infof("[import] Streaming data for group [%d] from directory: [%s]", group, pDir)
if err := streamSnapshotForGroup(errGrpCtx, dc, pDir, group); err != nil {
glog.Errorf("[import] Failed to stream data for group [%v] from directory: [%s]: %v", group, pDir, err)
return err
}
return nil
})
}
if err := errG.Wait(); err != nil {
glog.Errorf("[import] failed to stream external snapshot: %v", err)
// If errors occurs during streaming of the external snapshot, we drop all the data and
// go back to ensure a clean slate and the cluster remains in working state.
glog.Info("[import] dropping all the data and going back to clean slate")
req := &api.UpdateExtSnapshotStreamingStateRequest{
Start: false,View on GitHub (pinned to 759e242be6)
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.
Example fix
// before err := dgraphimport.Import(ctx, addr, "/data/bulk_output/shards") // wrong level: p dirs live in 0/p, 1/p // after err := dgraphimport.Import(ctx, addr, "/data/bulk_output") // root containing <group-1>/p
Defensive patterns
Strategy: validation
Validate before calling
if err := validateBulkLayout(bulkDir, groups); err != nil { return err }
func validateBulkLayout(base string, groups []uint32) error {
for _, g := range groups {
p := filepath.Join(base, fmt.Sprintf("%d", g-1), "p")
if _, err := os.Stat(p); err != nil {
return fmt.Errorf("missing %s for group %d", p, g)
}
}
return nil
} Try / catch
if err := dgraphimport.Import(ctx, addr, bulkDir); err != nil {
if strings.Contains(err.Error(), "p directory does not exist") {
return fmt.Errorf("bulk output layout mismatch: expected <root>/<group-1>/p; got root %q", bulkDir)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- bulk output directory cannot be empty
- missing or empty directory
- error creating indexer for %s: %w
- error while creating debug file: %s
- error while creating temporary directory: %s
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/063f8faff4be5104.
Report an issue: GitHub.