Skip to content
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

Native support for incremental restore #13239

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/rocksdb/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ class Env : public Customizable {
const EnvOptions& env_options,
const ImmutableDBOptions& immutable_ops) const;

// OptimizeForCompactionTableWrite will create a new EnvOptions object that
// OptimizeForCompactionTableRead will create a new EnvOptions object that
// is a copy of the EnvOptions in the parameters, but is optimized for reading
// table files.
virtual EnvOptions OptimizeForCompactionTableRead(
Expand Down
46 changes: 42 additions & 4 deletions include/rocksdb/utilities/backup_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ struct BackupEngineOptions {
// Default: true
bool share_files_with_checksum;

// Up to this many background threads will copy files for CreateNewBackup()
// and RestoreDBFromBackup()
// Up to this many background threads will be used to copy files & compute
// checksums for CreateNewBackup() and RestoreDBFromBackup().
// Default: 1
int max_background_operations;

Expand Down Expand Up @@ -349,6 +349,39 @@ struct CreateBackupOptions {
};

struct RestoreOptions {
// Enum reflecting tiered approach to restores.
//
// Options `kKeepLatestDbSessionIdFiles`, `kVerifyChecksum` introduce
// incremental restore capability and are intended to be used separately.
enum Mode : uint32_t {
// Most efficient way to restore a healthy / non-corrupted DB from
// the backup(s). This mode can almost always successfully recover from
// incomplete / missing files, as in an incomplete copy of a DB.
// This mode is also integrated with `exclude_files_callback` feature
// and will opportunistically try to find excluded files in existing db
// filesystem if missing in all supplied backup directories.
//
// Effective on data files following modern share files naming schemes.
kKeepLatestDbSessionIdFiles = 1U,

// Recommended when db is suspected to be unhealthy, ex. we want to retain
// most of the files (therefore saving on write I/O) with an exception of
// a few corrupted ones.
//
// When opted-in, restore engine will scan the db file, compute the
mszeszko-meta marked this conversation as resolved.
Show resolved Hide resolved
// checksum and compare it against the checksum hardened in the backup file
// metadata. If checksums match, existing file will be retained as-is.
// Otherwise, it will be deleted and replaced it with its' restored backup
// counterpart. If backup file doesn't have a checksum hardened in the
// metadata, we'll schedule an async task to compute it.
kVerifyChecksum = 2U,

// Zero trust. Least efficient.
//
// Purge all the destination files and restores all files from the backup.
kPurgeAllFiles = 0xffffU,
};

// If true, restore won't overwrite the existing log files in wal_dir. It will
// also move all log files from archive directory to wal_dir. Use this option
// in combination with BackupEngineOptions::backup_log_files = false for
Expand All @@ -361,8 +394,13 @@ struct RestoreOptions {
// directories known to contain the required files.
std::forward_list<BackupEngineReadOnlyBase*> alternate_dirs;

explicit RestoreOptions(bool _keep_log_files = false)
: keep_log_files(_keep_log_files) {}
// Specifies the level of incremental restore. 'kPurgeAllFiles' by default.
Mode mode;

// FIXME(https://github.com/facebook/rocksdb/issues/13293)
explicit RestoreOptions(bool _keep_log_files = false,
mszeszko-meta marked this conversation as resolved.
Show resolved Hide resolved
Mode _mode = Mode::kPurgeAllFiles)
: keep_log_files(_keep_log_files), mode(_mode) {}
};

using BackupID = uint32_t;
Expand Down
Loading
Loading