Browse Source

add debug message when only zeros are copied

avoid_releasing_temp_file_on_write
chrislu 3 years ago
parent
commit
fd83009c05
  1. 16
      weed/filesys/page_writer/chunked_stream_writer.go

16
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)

Loading…
Cancel
Save