From fd83009c058b0264b18f6ec39994ab9eb9836007 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 15 Jan 2022 14:39:23 -0800 Subject: [PATCH] add debug message when only zeros are copied --- .../filesys/page_writer/chunked_stream_writer.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/weed/filesys/page_writer/chunked_stream_writer.go b/weed/filesys/page_writer/chunked_stream_writer.go index 4bc49765b..6c7136645 100644 --- a/weed/filesys/page_writer/chunked_stream_writer.go +++ b/weed/filesys/page_writer/chunked_stream_writer.go @@ -1,6 +1,7 @@ package page_writer import ( + "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util/mem" "io" @@ -80,6 +81,18 @@ func (cw *ChunkedStreamWriter) ReadDataAt(p []byte, off int64) (maxStop int64) { if logicStart < logicStop { copy(p[logicStart-off:logicStop-off], memChunk.buf[logicStart-memChunkBaseOffset:logicStop-memChunkBaseOffset]) maxStop = max(maxStop, logicStop) + + isAllZero := true + for i := logicStart - off; i < logicStop-off; i++ { + if p[i] != 0 { + isAllZero = false + break + } + } + if isAllZero { + glog.Errorf("Copied content is all Zero [%d,%d)", logicStart-off, logicStop-off) + } + } } return @@ -111,6 +124,9 @@ func (cw *ChunkedStreamWriter) saveOneChunk(memChunk *MemChunk, logicChunkIndex // Destroy releases used resources func (cw *ChunkedStreamWriter) Destroy() { + cw.Lock() + defer cw.Unlock() + for t, memChunk := range cw.activeChunks { mem.Free(memChunk.buf) delete(cw.activeChunks, t)