-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate page being fetched at possition 'p' self identifies as page 'p' #358
Conversation
ac8b257
to
95cd20f
Compare
page.go
Outdated
@@ -53,6 +54,19 @@ func (p *page) meta() *meta { | |||
return (*meta)(unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))) | |||
} | |||
|
|||
func (p *page) fastCheck(id pgid) { | |||
if p.id != id { | |||
log.Panicf("Page expected to be: %v, but self identifies as %v", id, p.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just panic? Usually bbolt is supposed to be embedded in the client application, and we either return an error or panic directly. It might not be good to write a log to stderr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Used assert.
page.go
Outdated
p.flags != leafPageFlag && | ||
p.flags != metaPageFlag && | ||
p.flags != freelistPageFlag { | ||
log.Panicf("page %v: has unexpected type/flags: %x", p.id, p.flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Used assert.
…'p'. It's the easiest verification whether the page is actually written, or its 'random' garbage in the block. Signed-off-by: Piotr Tabor <ptab@google.com>
Signed-off-by: Piotr Tabor <ptab@google.com>
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>
95cd20f
to
86ce028
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @ptabor
Thank you. |
It's the easiest verification whether the page is actually written, or its 'random' garbage in the block.
For example for corruption from '#335' it will fail quickly with:
Signed-off-by: Piotr Tabor ptab@google.com