From 39eaa37dcfc2adb0bb221384c4f7e83bed3f791e Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Wed, 8 Jun 2016 10:57:14 -0700 Subject: [PATCH] wal: warn if sync exceeds a second --- wal/wal.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wal/wal.go b/wal/wal.go index 9da6f636e..f5913ffc0 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -47,6 +47,10 @@ const ( // the expected size of each wal segment file. // the actual size might be bigger than it. segmentSizeBytes = 64 * 1000 * 1000 // 64MB + + // warnSyncDuration is the amount of time allotted to an fsync before + // logging a warning + warnSyncDuration = time.Second ) var ( @@ -393,7 +397,13 @@ func (w *WAL) sync() error { } start := time.Now() err := fileutil.Fdatasync(w.tail().File) - syncDurations.Observe(time.Since(start).Seconds()) + + duration := time.Since(start) + if duration > warnSyncDuration { + plog.Warningf("sync duration of %v, expected less than %v", duration, warnSyncDuration) + } + syncDurations.Observe(duration.Seconds()) + return err }