fix(split): add flush_memtable for copy_checkpoint_to_dir (#684)
diff --git a/rdsn b/rdsn
index ab9520d..7404376 160000
--- a/rdsn
+++ b/rdsn
@@ -1 +1 @@
-Subproject commit ab9520df9bb47be2eb7d5720098ff463cd83ec36
+Subproject commit 7404376b45cde468df2435cab3f6913fe7e2dd40
diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp
index fb7b600..38b15d7 100644
--- a/src/server/pegasus_server_impl.cpp
+++ b/src/server/pegasus_server_impl.cpp
@@ -1802,19 +1802,21 @@
// Must be thread safe.
::dsn::error_code pegasus_server_impl::copy_checkpoint_to_dir(const char *checkpoint_dir,
- /*output*/ int64_t *last_decree)
+ /*output*/ int64_t *last_decree,
+ bool flush_memtable)
{
CheckpointingTokenHelper token_helper(_is_checkpointing);
if (!token_helper.token_got()) {
return ::dsn::ERR_WRONG_TIMING;
}
- return copy_checkpoint_to_dir_unsafe(checkpoint_dir, last_decree);
+ return copy_checkpoint_to_dir_unsafe(checkpoint_dir, last_decree, flush_memtable);
}
// not thread safe, should be protected by caller
::dsn::error_code pegasus_server_impl::copy_checkpoint_to_dir_unsafe(const char *checkpoint_dir,
- int64_t *checkpoint_decree)
+ int64_t *checkpoint_decree,
+ bool flush_memtable)
{
rocksdb::Checkpoint *chkpt_raw = nullptr;
auto status = rocksdb::Checkpoint::Create(_db, &chkpt_raw);
@@ -1834,7 +1836,8 @@
}
// CreateCheckpoint() will not flush memtable when log_size_for_flush = max
- status = chkpt->CreateCheckpoint(checkpoint_dir, std::numeric_limits<uint64_t>::max());
+ status = chkpt->CreateCheckpoint(checkpoint_dir,
+ flush_memtable ? 0 : std::numeric_limits<uint64_t>::max());
if (!status.ok()) {
derror_replica("CreateCheckpoint failed, error = {}", status.ToString());
if (!::dsn::utils::filesystem::remove_path(checkpoint_dir)) {
diff --git a/src/server/pegasus_server_impl.h b/src/server/pegasus_server_impl.h
index 1703dd7..5785624 100644
--- a/src/server/pegasus_server_impl.h
+++ b/src/server/pegasus_server_impl.h
@@ -124,13 +124,15 @@
// must be thread safe
// this method will not trigger flush(), just copy even if the app is empty.
::dsn::error_code copy_checkpoint_to_dir(const char *checkpoint_dir,
- /*output*/ int64_t *last_decree) override;
+ /*output*/ int64_t *last_decree,
+ bool flush_memtable = false) override;
//
// help function, just copy checkpoint to specified dir and ignore _is_checkpointing.
// if checkpoint_dir already exist, this function will delete it first.
::dsn::error_code copy_checkpoint_to_dir_unsafe(const char *checkpoint_dir,
- /**output*/ int64_t *checkpoint_decree);
+ /**output*/ int64_t *checkpoint_decree,
+ bool flush_memtable = false);
// get the last checkpoint
// if succeed: