Optional sequence number exporting during checkpoint creation (#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: https://github.com/facebook/rocksdb/pull/5528

Test Plan: make check -j64

Reviewed By: Winger1994

Differential Revision: D16080209

fbshipit-source-id: 6dc3c7680287ee97d673c5e61f89aae1f43e33df
main
Chao Zhao 5 years ago committed by Facebook Github Bot
parent fd1da22111
commit 4028eba67b
  1. 6
      include/rocksdb/utilities/checkpoint.h
  2. 9
      utilities/checkpoint/checkpoint_impl.cc
  3. 3
      utilities/checkpoint/checkpoint_impl.h

@ -37,8 +37,12 @@ class Checkpoint {
// away from the default, the checkpoint may not contain up-to-date data
// if WAL writing is not always enabled.
// Flush will always trigger if it is 2PC.
// sequence_number_ptr: if it is not nullptr, the value it points to will be
// set to the DB's sequence number. The default value of this parameter is
// nullptr.
virtual Status CreateCheckpoint(const std::string& checkpoint_dir,
uint64_t log_size_for_flush = 0);
uint64_t log_size_for_flush = 0,
uint64_t* sequence_number_ptr = nullptr);
// Exports all live SST files of a specified Column Family onto export_dir,
// returning SST files information in metadata.

@ -35,7 +35,8 @@ Status Checkpoint::Create(DB* db, Checkpoint** checkpoint_ptr) {
}
Status Checkpoint::CreateCheckpoint(const std::string& /*checkpoint_dir*/,
uint64_t /*log_size_for_flush*/) {
uint64_t /*log_size_for_flush*/,
uint64_t* /*sequence_number_ptr*/) {
return Status::NotSupported("");
}
@ -69,7 +70,8 @@ Status Checkpoint::ExportColumnFamily(
// Builds an openable snapshot of RocksDB
Status CheckpointImpl::CreateCheckpoint(const std::string& checkpoint_dir,
uint64_t log_size_for_flush) {
uint64_t log_size_for_flush,
uint64_t* sequence_number_ptr) {
DBOptions db_options = db_->GetDBOptions();
Status s = db_->GetEnv()->FileExists(checkpoint_dir);
@ -145,6 +147,9 @@ Status CheckpointImpl::CreateCheckpoint(const std::string& checkpoint_dir,
}
if (s.ok()) {
if (sequence_number_ptr != nullptr) {
*sequence_number_ptr = sequence_number;
}
// here we know that we succeeded and installed the new snapshot
ROCKS_LOG_INFO(db_options.info_log, "Snapshot DONE. All is good");
ROCKS_LOG_INFO(db_options.info_log, "Snapshot sequence number: %" PRIu64,

@ -28,7 +28,8 @@ class CheckpointImpl : public Checkpoint {
// The directory will be an absolute path
using Checkpoint::CreateCheckpoint;
virtual Status CreateCheckpoint(const std::string& checkpoint_dir,
uint64_t log_size_for_flush) override;
uint64_t log_size_for_flush,
uint64_t* sequence_number_ptr) override;
// Exports all live SST files of a specified Column Family onto export_dir
// and returning SST files information in metadata.

Loading…
Cancel
Save