dgraph-io/dgraph · error
Create path failed to create path %s, got error: %v
Error message
Create path failed to create path %s, got error: %v
What it means
fileHandler.CreateDir wraps os.MkdirAll failures with this message, embedding the resolved path and the OS error. It means the local-filesystem handler could not create (recursively) the directory needed for a backup or export operation. The message deliberately includes both the path and the underlying cause for diagnosis.
Source
Thrown at worker/backup_handler.go:189
func (h *fileHandler) FileExists(path string) bool { return pathExist(h.JoinPath(path)) }
func (h *fileHandler) Read(path string) ([]byte, error) { return os.ReadFile(h.JoinPath(path)) }
func (h *fileHandler) JoinPath(path string) string {
return filepath.Join(h.rootDir, h.prefix, cleanRelPath(path))
}
func (h *fileHandler) Stream(path string) (io.ReadCloser, error) {
return os.Open(h.JoinPath(path))
}
func (h *fileHandler) ListPaths(path string) []string {
path = h.JoinPath(path)
return x.WalkPathFunc(path, func(path string, isDis bool) bool {
return true
})
}
func (h *fileHandler) CreateDir(path string) error {
path = h.JoinPath(path)
if err := os.MkdirAll(path, 0755); err != nil {
return errors.Errorf("Create path failed to create path %s, got error: %v", path, err)
}
return nil
}
type fileSyncer struct {
fp *os.File
}
func (fs *fileSyncer) Write(p []byte) (n int, err error) { return fs.fp.Write(p) }
func (fs *fileSyncer) Close() error {
if err := fs.fp.Sync(); err != nil {
return errors.Wrapf(err, "while syncing file: %s", fs.fp.Name())
}
err := fs.fp.Close()
return errors.Wrapf(err, "while closing file: %s", fs.fp.Name())
}
func (h *fileHandler) CreateFile(path string) (io.WriteCloser, error) {View on GitHub (pinned to 759e242be6)
Solutions
- Read the wrapped %v cause to see the exact errno (EACCES, ENOSPC, ENOTDIR, EROFS).
- Verify/fix permissions: chown/chmod the parent directory for the worker user.
- Remove or rename any non-directory file occupying the target path.
- Check disk space and mount status (df -h, mount) for ENOSPC or ro filesystems.
- If path is outside the intended root, fix the URI/rootDir configuration.
Example fix
// before
if err := os.MkdirAll(path, 0755); err != nil {
return errors.Errorf("Create path failed to create path %s, got error: %v", path, err)
}
// after
if err := os.MkdirAll(path, 0755); err != nil {
if errors.Is(err, os.ErrPermission) {
return errors.Errorf("Create path failed to create path %s: permission denied; check worker user owns parent", path)
}
return errors.Errorf("Create path failed to create path %s, got error: %v", path, err)
} Defensive patterns
Strategy: validation
Validate before calling
root := handlerRootDir()
if info, err := os.Stat(root); err != nil || !info.IsDir() {
return fmt.Errorf("backup root %s missing or not a directory", root)
}
if err := unix.Access(root, unix.W_OK); err != nil {
return fmt.Errorf("backup root %s not writable: %v", root, err)
} Type guard
func canCreateDir(root string) bool {
f, err := os.CreateTemp(root, ".writetest*")
if err != nil { return false }
f.Close()
os.Remove(f.Name())
return true
} Try / catch
if err := handler.CreateDir(dir); err != nil {
var pe *os.PathError
if errors.As(err, &pe) {
log.Printf("mkdir failed path=%s op=%s cause=%v", pe.Path, pe.Op, pe.Err)
}
return err
} Prevention
- Provision and chown the backup root during deployment.
- Avoid nesting backup dirs under mount points that may go read-only.
- Test directory creation in health checks.
- Monitor free space so backup roots never sit on full disks.
When it happens
Trigger: os.MkdirAll(path, 0755) fails: parent directory not writable, path component is a file, permission denied, disk full, or read-only filesystem on the JoinPath-resolved path under the handler's rootDir.
Common situations: Worker lacks write permission on the backup root; a file exists where a directory is expected; container running with read-only rootfs; NFS stale-handle issues on network mounts; path length limits exceeded.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- error while creating debug file: %s
- File handler failed to create file %s
- RunRestore failed to write group id file
- error while creating temporary directory: %s
- error while archiving debuginfo directory: %s
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/4ddb6b95224ac95b.
Report an issue: GitHub.