Skip to content

Commit 4028eba

Browse files
Chao Zhaofacebook-github-bot
authored andcommitted
Optional sequence number exporting during checkpoint creation (facebook#5528)
Summary: Add sequence_number_ptr to the checkpoint interface to expose the sequence number during taking the checkpoint. The number will be consistent with the seq # in rocksdb log. Pull Request resolved: facebook#5528 Test Plan: make check -j64 Reviewed By: Winger1994 Differential Revision: D16080209 fbshipit-source-id: 6dc3c7680287ee97d673c5e61f89aae1f43e33df
1 parent fd1da22 commit 4028eba

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

include/rocksdb/utilities/checkpoint.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ class Checkpoint {
3737
// away from the default, the checkpoint may not contain up-to-date data
3838
// if WAL writing is not always enabled.
3939
// Flush will always trigger if it is 2PC.
40+
// sequence_number_ptr: if it is not nullptr, the value it points to will be
41+
// set to the DB's sequence number. The default value of this parameter is
42+
// nullptr.
4043
virtual Status CreateCheckpoint(const std::string& checkpoint_dir,
41-
uint64_t log_size_for_flush = 0);
44+
uint64_t log_size_for_flush = 0,
45+
uint64_t* sequence_number_ptr = nullptr);
4246

4347
// Exports all live SST files of a specified Column Family onto export_dir,
4448
// returning SST files information in metadata.

utilities/checkpoint/checkpoint_impl.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Status Checkpoint::Create(DB* db, Checkpoint** checkpoint_ptr) {
3535
}
3636

3737
Status Checkpoint::CreateCheckpoint(const std::string& /*checkpoint_dir*/,
38-
uint64_t /*log_size_for_flush*/) {
38+
uint64_t /*log_size_for_flush*/,
39+
uint64_t* /*sequence_number_ptr*/) {
3940
return Status::NotSupported("");
4041
}
4142

@@ -69,7 +70,8 @@ Status Checkpoint::ExportColumnFamily(
6970

7071
// Builds an openable snapshot of RocksDB
7172
Status CheckpointImpl::CreateCheckpoint(const std::string& checkpoint_dir,
72-
uint64_t log_size_for_flush) {
73+
uint64_t log_size_for_flush,
74+
uint64_t* sequence_number_ptr) {
7375
DBOptions db_options = db_->GetDBOptions();
7476

7577
Status s = db_->GetEnv()->FileExists(checkpoint_dir);
@@ -145,6 +147,9 @@ Status CheckpointImpl::CreateCheckpoint(const std::string& checkpoint_dir,
145147
}
146148

147149
if (s.ok()) {
150+
if (sequence_number_ptr != nullptr) {
151+
*sequence_number_ptr = sequence_number;
152+
}
148153
// here we know that we succeeded and installed the new snapshot
149154
ROCKS_LOG_INFO(db_options.info_log, "Snapshot DONE. All is good");
150155
ROCKS_LOG_INFO(db_options.info_log, "Snapshot sequence number: %" PRIu64,

utilities/checkpoint/checkpoint_impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class CheckpointImpl : public Checkpoint {
2828
// The directory will be an absolute path
2929
using Checkpoint::CreateCheckpoint;
3030
virtual Status CreateCheckpoint(const std::string& checkpoint_dir,
31-
uint64_t log_size_for_flush) override;
31+
uint64_t log_size_for_flush,
32+
uint64_t* sequence_number_ptr) override;
3233

3334
// Exports all live SST files of a specified Column Family onto export_dir
3435
// and returning SST files information in metadata.

0 commit comments

Comments
 (0)