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
Pages checksum verification #736
Conversation
e39e8df
to
e694378
Compare
e694378
to
4183043
Compare
} | ||
fileReader, cfi.header.Size, err = ReadIncrementalFile(cfi.path, cfi.fileInfo.Size(), *p.incrementFromLsn, bitmap) |
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.
I've renamed fileReader to fileReadCloser because actually it is ReadCloser, not only reader
4183043
to
1dc6796
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.
Looks good
internal/backup_file_description.go
Outdated
|
||
type BackupFileDescription struct { | ||
IsIncremented bool // should never be both incremented and Skipped | ||
IsSkipped bool | ||
MTime time.Time | ||
CorruptBlocks []uint32 `json:",omitempty"` |
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.
Add the actual number of corrupted blocks. Sometimes it helps to distinguish different bugs.
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.
And maybe a flag to keep all blocks.
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.
Added in 50e27bd
func (m *MultiCloser) Close() error { | ||
var err error | ||
for _, c := range m.closers { | ||
// still call Close on each, even if one returns an error |
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.
hm, it will be better to save all error messages. You can combine it to a new error
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.
Fixed in 4efeef1
"unsafe" | ||
) | ||
|
||
// This code is an adaptation of Postgres data page checksum calculation code written in Go. |
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.
I will trust that it has the same code.
} | ||
|
||
// VerifyPagedFileIncrement verifies pages of an increment | ||
func VerifyPagedFileIncrement(path string, fileInfo os.FileInfo, increment io.Reader) ([]uint32, error) { |
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.
This part is OK
599523f
to
50e27bd
Compare
@usernamedt awesome features! discovered by accident. Couldn't find anything in README or Postgres-related .md doc file. Could you please add info there? (I can help, but it would be good to have at least a draft) |
Hi, thanks for noting this, seems like I forgot to add documentation for this feature :) I'll fix this soon. As for now, I have a more or less detailed description here. |
In this PR I propose the page checksums verification functionality for
backup-push
I've adapted the Postgres page hash calculation (modified version of FNV-1a hash algorithm) from C origin:
https://github.com/postgres/postgres/blob/REL_12_STABLE/src/include/storage/checksum_impl.h
Also, I've also partially borrowed the logic of is_page_corrupted() from pg_page_verification tool: https://github.com/google/pg_page_verification/blob/master/pg_page_verification.c
Users can enable the page verification using
--verify
flag or by settingWALG_VERIFY_PAGE_CHECKSUMS
env variable. If found any, corrupted block numbers (currently no more than 10 of them) will be recorded to the backup sentinel json, for example: