MCPcopy Create free account
hub / github.com/apache/kvrocks / AsyncBgSaveDB

Method AsyncBgSaveDB

src/server/server.cc:1675–1694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1673}
1674
1675Status Server::AsyncBgSaveDB() {
1676 std::lock_guard<std::mutex> lg(db_job_mu_);
1677 if (is_bgsave_in_progress_) {
1678 return {Status::NotOK, "bgsave in-progress"};
1679 }
1680
1681 is_bgsave_in_progress_ = true;
1682
1683 return task_runner_.TryPublish([this] {
1684 auto start_bgsave_time_secs = util::GetTimeStamp<std::chrono::seconds>();
1685 Status s = storage->CreateBackup();
1686 auto stop_bgsave_time_secs = util::GetTimeStamp<std::chrono::seconds>();
1687
1688 std::lock_guard<std::mutex> lg(db_job_mu_);
1689 is_bgsave_in_progress_ = false;
1690 last_bgsave_timestamp_secs_ = start_bgsave_time_secs;
1691 last_bgsave_status_ = s.IsOK() ? "ok" : "err";
1692 last_bgsave_duration_secs_ = stop_bgsave_time_secs - start_bgsave_time_secs;
1693 });
1694}
1695
1696Status Server::AsyncPurgeOldBackups(uint32_t num_backups_to_keep, uint32_t backup_max_keep_hours) {
1697 return task_runner_.TryPublish([num_backups_to_keep, backup_max_keep_hours, this] {

Callers 1

ExecuteMethod · 0.80

Calls 3

TryPublishMethod · 0.80
CreateBackupMethod · 0.80
IsOKMethod · 0.45

Tested by

no test coverage detected