From 57027657299476f1ec6cb1e6d5f46703c56899e2 Mon Sep 17 00:00:00 2001 From: SimFG <1142838399@qq.com> Date: Thu, 22 Sep 2022 16:21:46 +0800 Subject: [PATCH] wal: Fix the `walWriteBytes` metric Signed-off-by: SimFG <1142838399@qq.com> --- pkg/ioutil/pagewriter.go | 5 ----- server/storage/wal/encoder.go | 6 ++---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/ioutil/pagewriter.go b/pkg/ioutil/pagewriter.go index 83c856d66..ebab6487e 100644 --- a/pkg/ioutil/pagewriter.go +++ b/pkg/ioutil/pagewriter.go @@ -104,11 +104,6 @@ func (pw *PageWriter) Flush() error { return err } -// FlushN flushes buffered data and returns the number of written bytes. -func (pw *PageWriter) FlushN() (int, error) { - return pw.flush() -} - func (pw *PageWriter) flush() (int, error) { if pw.bufferedBytes == 0 { return 0, nil diff --git a/server/storage/wal/encoder.go b/server/storage/wal/encoder.go index d9e221ff2..6d1f97ad6 100644 --- a/server/storage/wal/encoder.go +++ b/server/storage/wal/encoder.go @@ -109,10 +109,8 @@ func encodeFrameSize(dataBytes int) (lenField uint64, padBytes int) { func (e *encoder) flush() error { e.mu.Lock() - n, err := e.bw.FlushN() - e.mu.Unlock() - walWriteBytes.Add(float64(n)) - return err + defer e.mu.Unlock() + return e.bw.Flush() } func writeUint64(w io.Writer, n uint64, buf []byte) error {