Skip to content

Commit

Permalink
fix(rocksdb): fix the problem that the usage of block cache is not se…
Browse files Browse the repository at this point in the history
…t for the metric (apache#2060)

apache#2061

The monitor of the block cache usage is server-level and created by
std::call_once in a replica-level object, running periodically to update
the block cache usage.

However, once the replica-level object is stopped, the server-level
monitor would be cancelled; as a result, the block cache usage would
never be updated.
  • Loading branch information
empiredan authored Jul 5, 2024
1 parent 57dd0e1 commit 3f78d22
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/server/pegasus_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,12 @@ dsn::error_code pegasus_server_impl::start(int argc, char **argv)
std::call_once(flag, [&]() {
// The timer task will always running even though there is no replicas
CHECK_NE(kServerStatUpdateTimeSec.count(), 0);

// TODO(wangdan): _update_server_rdb_stat is server-level, thus it could not be simply
// cancelled in the destructor of pegasus_server_impl which is replica-level.
//
// We should refactor to make _update_server_rdb_stat exit gracefully by
// `_update_server_rdb_stat->cancel(true)`.
_update_server_rdb_stat = dsn::tasking::enqueue_timer(
LPC_REPLICATION_LONG_COMMON,
nullptr, // TODO: the tracker is nullptr, we will fix it later
Expand Down Expand Up @@ -1869,10 +1875,7 @@ ::dsn::error_code pegasus_server_impl::stop(bool clear_state)
_update_replica_rdb_stat->cancel(true);
_update_replica_rdb_stat = nullptr;
}
if (_update_server_rdb_stat != nullptr) {
_update_server_rdb_stat->cancel(true);
_update_server_rdb_stat = nullptr;
}

_tracker.cancel_outstanding_tasks();

_context_cache.clear();
Expand Down

0 comments on commit 3f78d22

Please sign in to comment.