Skip to content

Commit

Permalink
Defensive: Expect page that node writes onto to be zeroed.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ptabor committed Dec 23, 2022
1 parent 3cbd9c9 commit 86ce028
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 86ce028

Please sign in to comment.