Browse Source

add debug zero

avoid_releasing_temp_file_on_write
chrislu 3 years ago
parent
commit
cb25d100b7
  1. 2
      weed/filesys/page_writer.go
  2. 1
      weed/filesys/page_writer/chunked_file_writer.go
  3. 12
      weed/filesys/page_writer/chunked_stream_writer.go
  4. 17
      weed/filesys/page_writer/debug_content.go

2
weed/filesys/page_writer.go

@ -84,6 +84,8 @@ func (pw *PageWriter) ReadDirtyDataAt(data []byte, offset int64) (maxStop int64)
data = data[readSize:] data = data[readSize:]
} }
checkByteZero("page writer read", p, 0, maxStop-offset)
return return
} }

1
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) glog.Errorf("reading temp file: %v", err)
break break
} }
checkByteZero("temp file writer read", p, logicStart-off, logicStop-off)
maxStop = max(maxStop, logicStop) maxStop = max(maxStop, logicStop)
} }
} }

12
weed/filesys/page_writer/chunked_stream_writer.go

@ -1,7 +1,6 @@
package page_writer package page_writer
import ( import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/util/mem" "github.com/chrislusf/seaweedfs/weed/util/mem"
"io" "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]) copy(p[logicStart-off:logicStop-off], memChunk.buf[logicStart-memChunkBaseOffset:logicStop-memChunkBaseOffset])
maxStop = max(maxStop, logicStop) 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)
} }
} }

17
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)
}
}
Loading…
Cancel
Save