Skip to content

Commit

Permalink
Turn the default Timer in PeriodicTaskScheduler into a leaky Meyers s…
Browse files Browse the repository at this point in the history
…ingleton (#12128)

Summary:
Pull Request resolved: #12128

The patch turns the `Timer` Meyers singleton in `PeriodicTaskScheduler::Default()` into one of the leaky variety in order to prevent static destruction order issues.

Reviewed By: akankshamahajan15

Differential Revision: D51963950

fbshipit-source-id: 0fc34113ad03c51fdc83bdb8c2cfb6c9f6913948
  • Loading branch information
ltamasi committed Dec 8, 2023
1 parent 3b1ce12 commit b8d41c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions db/periodic_task_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Status PeriodicTaskScheduler::Unregister(PeriodicTaskType task_type) {
}

Timer* PeriodicTaskScheduler::Default() {
static Timer timer(SystemClock::Default().get());
STATIC_AVOID_DESTRUCTION(Timer, timer)(SystemClock::Default().get());
return &timer;
}

Expand All @@ -108,4 +108,3 @@ void PeriodicTaskScheduler::TEST_OverrideTimer(SystemClock* clock) {
#endif // NDEBUG

} // namespace ROCKSDB_NAMESPACE

1 change: 1 addition & 0 deletions unreleased_history/bug_fixes/avoid_destroying_timer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid destroying the periodic task scheduler's default timer in order to prevent static destruction order issues.

0 comments on commit b8d41c5

Please sign in to comment.