jihuayu commented on code in PR #3559:
URL: https://github.com/apache/kvrocks/pull/3559#discussion_r3591779586
##########
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:
With the current logic, the checkpoint can still be purged while it is in
use because `GetFetchFileThreadNum()` is checked outside the lock.
The locking here does not seem sufficient. Could you take a look? @git-hulk
@PragmaTwice
--
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]