adamdebreceni commented on code in PR #1516: URL: https://github.com/apache/nifi-minifi-cpp/pull/1516#discussion_r1119993446
########## extensions/rocksdb-repos/DatabaseContentRepository.cpp: ########## @@ -72,13 +87,40 @@ bool DatabaseContentRepository::initialize(const std::shared_ptr<minifi::Configu return is_valid_; } +void DatabaseContentRepository::runCompaction() { + do { + if (auto opendb = db_->open()) { + auto status = opendb->RunCompaction(); + logger_->log_trace("Compaction triggered: %s", status.ToString()); + } else { + logger_->log_error("Failed to open database for compaction"); + } + } while (!utils::StoppableThread::wait_stop_requested(compaction_period_)); +} + +void DatabaseContentRepository::start() { + if (!db_ || !is_valid_) { + return; + } + if (compaction_period_.count() != 0) { + compaction_thread_ = std::make_unique<utils::StoppableThread>([this] () { + runCompaction(); + }); + } +} + void DatabaseContentRepository::stop() { if (db_) { auto opendb = db_->open(); if (opendb) { opendb->FlushWAL(true); } + compaction_thread_.reset(); Review Comment: the thread's destructor called during reset block until it is joined ########## extensions/rocksdb-repos/DatabaseContentRepository.cpp: ########## @@ -72,13 +87,40 @@ bool DatabaseContentRepository::initialize(const std::shared_ptr<minifi::Configu return is_valid_; } +void DatabaseContentRepository::runCompaction() { + do { + if (auto opendb = db_->open()) { + auto status = opendb->RunCompaction(); + logger_->log_trace("Compaction triggered: %s", status.ToString()); + } else { + logger_->log_error("Failed to open database for compaction"); + } + } while (!utils::StoppableThread::wait_stop_requested(compaction_period_)); +} + +void DatabaseContentRepository::start() { + if (!db_ || !is_valid_) { + return; + } + if (compaction_period_.count() != 0) { + compaction_thread_ = std::make_unique<utils::StoppableThread>([this] () { + runCompaction(); + }); + } +} + void DatabaseContentRepository::stop() { if (db_) { auto opendb = db_->open(); if (opendb) { opendb->FlushWAL(true); } + compaction_thread_.reset(); Review Comment: the thread's destructor called during reset blocks until it is joined -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org