From cb25d100b7ef44ce1e27e0d1f4a965e1acc7b098 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 15 Jan 2022 14:49:59 -0800 Subject: [PATCH] add debug zero --- weed/filesys/page_writer.go | 2 ++ weed/filesys/page_writer/chunked_file_writer.go | 1 + .../page_writer/chunked_stream_writer.go | 12 +----------- weed/filesys/page_writer/debug_content.go | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 weed/filesys/page_writer/debug_content.go diff --git a/weed/filesys/page_writer.go b/weed/filesys/page_writer.go index 5c06bc44d..02b5f1f35 100644 --- a/weed/filesys/page_writer.go +++ b/weed/filesys/page_writer.go @@ -84,6 +84,8 @@ func (pw *PageWriter) ReadDirtyDataAt(data []byte, offset int64) (maxStop int64) data = data[readSize:] } + checkByteZero("page writer read", p, 0, maxStop-offset) + return } diff --git a/weed/filesys/page_writer/chunked_file_writer.go b/weed/filesys/page_writer/chunked_file_writer.go index d2f94dafd..948547878 100644 --- a/weed/filesys/page_writer/chunked_file_writer.go +++ b/weed/filesys/page_writer/chunked_file_writer.go @@ -73,6 +73,7 @@ func (cw *ChunkedFileWriter) ReadDataAt(p []byte, off int64) (maxStop int64) { glog.Errorf("reading temp file: %v", err) break } + checkByteZero("temp file writer read", p, logicStart-off, logicStop-off) maxStop = max(maxStop, logicStop) } } diff --git a/weed/filesys/page_writer/chunked_stream_writer.go b/weed/filesys/page_writer/chunked_stream_writer.go index 6c7136645..a38193131 100644 --- a/weed/filesys/page_writer/chunked_stream_writer.go +++ b/weed/filesys/page_writer/chunked_stream_writer.go @@ -1,7 +1,6 @@ package page_writer import ( - "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util/mem" "io" @@ -82,16 +81,7 @@ func (cw *ChunkedStreamWriter) ReadDataAt(p []byte, off int64) (maxStop int64) { 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) - } + checkByteZero("stream writer read", p, logicStart-off, logicStop-off) } } diff --git a/weed/filesys/page_writer/debug_content.go b/weed/filesys/page_writer/debug_content.go new file mode 100644 index 000000000..2e5734ced --- /dev/null +++ b/weed/filesys/page_writer/debug_content.go @@ -0,0 +1,17 @@ +package page_writer + +import "github.com/chrislusf/seaweedfs/weed/glog" + +func checkByteZero(message string, p []byte, start, stop int64) { + isAllZero := true + for i := start; i < stop; i++ { + if p[i] != 0 { + isAllZero = false + break + } + } + if isAllZero { + glog.Errorf("%s is all zeros [%d,%d)", message, start, stop) + } + +}