git-hulk commented on code in PR #3559:
URL: https://github.com/apache/kvrocks/pull/3559#discussion_r3608429128


##########
src/storage/storage.cc:
##########
@@ -1181,6 +1185,51 @@ bool Storage::ExistCheckpoint() {
 
 bool Storage::ExistSyncCheckpoint() { return 
env_->FileExists(config_->sync_checkpoint_dir).ok(); }
 
+Status Storage::TryPurgeCheckpoint(int fetch_file_threads) {
+  std::string trash_dir = config_->checkpoint_dir + ".trash";
+  if (env_->FileExists(trash_dir).ok()) {
+    auto s = rocksdb::DestroyDB(trash_dir, rocksdb::Options());
+    if (!s.ok()) {
+      WARN("[storage] Fail to clean stale checkpoint trash, error: {}", 
s.ToString());
+      return {Status::NotOK, s.ToString()};
+    }
+  }
+
+  {
+    std::lock_guard<std::mutex> lg(checkpoint_mu_);

Review Comment:
   We now have the condition check:`now_secs - access_time_secs > 30` to 
protect against this issue. And it should also have a low likelihood of being 
purged. For example, the time window between fetching metadata and files is 
more than 30s.
   
   But the risk should be low, we can increase the time window to mitigate this.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to