mirror of https://github.com/etcd-io/bbolt.git
Defensive: Expect page that node writes onto to be zeroed.
I've seen data corruption that seen like a random bit-flip or application on already allocated page. Signed-off-by: Piotr Tabor <ptab@google.com>pull/358/head
parent
3cbd9c9a44
commit
86ce028a52
4
node.go
4
node.go
|
@ -188,7 +188,11 @@ func (n *node) read(p *page) {
|
|||
}
|
||||
|
||||
// write writes the items onto one or more pages.
|
||||
// The page should have p.id (might be 0 for meta or bucket-inline page) and p.overflow set
|
||||
// and the rest should be zeroed.
|
||||
func (n *node) write(p *page) {
|
||||
_assert(p.count == 0 && p.flags == 0, "node cannot be written into a not empty page")
|
||||
|
||||
// Initialize page.
|
||||
if n.isLeaf {
|
||||
p.flags = leafPageFlag
|
||||
|
|
Loading…
Reference in New Issue