From b882d2b7c7b4262dcb41ee0d47a87ecd2a1c4f51 Mon Sep 17 00:00:00 2001 From: johncming Date: Sat, 6 Nov 2021 17:41:06 +0800 Subject: [PATCH] tsdb/wal: Avoid writing closed channel. (#9566) Signed-off-by: johncming --- tsdb/wal/wal.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tsdb/wal/wal.go b/tsdb/wal/wal.go index 872e83a4d..b2d370914 100644 --- a/tsdb/wal/wal.go +++ b/tsdb/wal/wal.go @@ -472,6 +472,10 @@ func (w *WAL) NextSegment() error { // nextSegment creates the next segment and closes the previous one. func (w *WAL) nextSegment() error { + if w.closed { + return errors.New("wal is closed") + } + // Only flush the current page if it actually holds data. if w.page.alloc > 0 { if err := w.flushPage(true); err != nil {