VictoriaMetrics/VictoriaMetrics · error
cannot open %q for preallocation: %w
Error message
cannot open %q for preallocation: %w
What it means
Fires in the Linux preallocateFile when os.OpenFile cannot open the target path (O_WRONLY|O_CREATE) prior to fallocate. Input at fault is the part file path; wrapped error is an open failure — missing parent directory, permissions, or a read-only filesystem.
Source
Thrown at lib/backup/fslocal/prealloc_linux.go:17
package fslocal
import (
"fmt"
"os"
"syscall"
)
const canPreallocate = true
func preallocateFile(path string, size int64) error {
if size <= 0 {
return nil
}
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return fmt.Errorf("cannot open %q for preallocation: %w", path, err)
}
err = syscall.Fallocate(int(f.Fd()), 0, 0, size)
if err1 := f.Close(); err1 != nil && err == nil {
err = err1
}
if err != nil {
return fmt.Errorf("cannot fallocate %d bytes for %q: %w", size, path, err)
}
return nil
}
View on GitHub (pinned to 5079fb58f1)
Solutions
- Ensure the parent directory exists and is writable
- Check filesystem is mounted read-write
- Disable preallocation (SkipPreallocation) as a workaround on unsupported filesystems
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at lib/backup/fslocal/prealloc_linux.go:17 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/d460df4a15cd0288.
Report an issue: GitHub.