-
Notifications
You must be signed in to change notification settings - Fork 129
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
feat: Restore zstd-compressed database backup #273
base: master
Are you sure you want to change the base?
Conversation
7b3ff2d
to
f6b85ed
Compare
I removed an unused function, and force-pushed. |
The database backup is compressed using zstd. This allows us to load the backup without having to decompress it beforehand.
f6b85ed
to
9466d72
Compare
err = db.Load(zr, runtime.NumCPU()) | ||
if errors.Is(err, zstd.ErrMagicMismatch) { | ||
glog.V(2).Infof("database file is not compressed with zstd, will load without decompressing") | ||
|
||
// We already loaded the database, advancing the file offset. To load the database again, | ||
// we must reset the offset to the start. | ||
if _, err := file.Seek(0, io.SeekStart); err != nil { | ||
return errors.Wrapf(err, "failed to to rewind to start of database restore file: %q", filename) | ||
} | ||
err = db.Load(file, runtime.NumCPU()) | ||
} | ||
if err != nil { |
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 wanted to check if the file is compressed or not before loading the database, but could not find a way to do that using the zstd package. Attempting to load the database is the best alternative I found.
CI failure appears to be unrelated to this change.
|
The database backup is compressed using zstd. This allows us to load the backup without having to decompress it beforehand.
Please note that this change is backward compatible: both compressed and uncompressed backups are supported. I have added an integration test (using an on-disk database) to ensure this.