From 54aac4ab7ede78451cbac990bb72977528d0a97f Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Mon, 6 Jun 2016 09:52:34 -0700 Subject: [PATCH 1/2] pkg/fileutil: fall back to truncate() if fallocate is interrupted Fixes #5558 --- pkg/fileutil/preallocate_unix.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/fileutil/preallocate_unix.go b/pkg/fileutil/preallocate_unix.go index fa595e043..60c68202a 100644 --- a/pkg/fileutil/preallocate_unix.go +++ b/pkg/fileutil/preallocate_unix.go @@ -26,8 +26,9 @@ func preallocExtend(f *os.File, sizeInBytes int64) error { err := syscall.Fallocate(int(f.Fd()), 0, 0, sizeInBytes) if err != nil { errno, ok := err.(syscall.Errno) - // treat not support as nil error - if ok && errno == syscall.ENOTSUP { + // not supported; fallback + // fallocate EINTRs frequently in some enviroments; fallback + if ok && (errno == syscall.ENOTSUP || errno == syscall.EINTR) { return preallocExtendTrunc(f, sizeInBytes) } } From 5be39d2c845aae8fc6e5e7e7efe53b2c26f242a4 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Mon, 6 Jun 2016 11:31:25 -0700 Subject: [PATCH 2/2] wal: don't preallocate on old tail file Code is only there to handle an edge case where the tail wasn't preallocated already (e.g., via old etcd version or a crash). It also triggers tmpfs corruption, so remove it. --- wal/wal.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/wal/wal.go b/wal/wal.go index 4140633f2..9da6f636e 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -207,17 +207,10 @@ func openAtIndex(dirpath string, snap walpb.Snapshot, write bool) (*WAL, error) // write reuses the file descriptors from read; don't close so // WAL can append without dropping the file lock w.readClose = nil - if _, _, err := parseWalName(path.Base(w.tail().Name())); err != nil { closer() return nil, err } - // don't resize file for preallocation in case tail is corrupted - if err := fileutil.Preallocate(w.tail().File, segmentSizeBytes, false); err != nil { - closer() - plog.Errorf("failed to allocate space when creating new wal file (%v)", err) - return nil, err - } w.fp = newFilePipeline(w.dir, segmentSizeBytes) }