Fix singleton destruction order of PosixEnv and SyncPoint (#3951)
Summary: Ensure the PosixEnv singleton is destroyed first since its destructor waits for background threads to all complete. This ensures background threads cannot hit sync points after the SyncPoint singleton is destroyed, which was previously possible. Closes https://github.com/facebook/rocksdb/pull/3951 Differential Revision: D8265295 Pulled By: ajkr fbshipit-source-id: 7738dd458c5d993a78377dd0420e82badada81ab
This commit is contained in:
parent
ab2254bedf
commit
2210152947
1
env/env_posix.cc
vendored
1
env/env_posix.cc
vendored
@ -1057,6 +1057,7 @@ Env* Env::Default() {
|
||||
// the destructor of static PosixEnv will go first, then the
|
||||
// the singletons of ThreadLocalPtr.
|
||||
ThreadLocalPtr::InitSingletons();
|
||||
INIT_SYNC_POINT_SINGLETONS();
|
||||
static PosixEnv default_env;
|
||||
return &default_env;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ extern void TestKillRandom(std::string kill_point, int odds,
|
||||
#define TEST_SYNC_POINT(x)
|
||||
#define TEST_IDX_SYNC_POINT(x, index)
|
||||
#define TEST_SYNC_POINT_CALLBACK(x, y)
|
||||
#define INIT_SYNC_POINT_SINGLETONS()
|
||||
#else
|
||||
|
||||
namespace rocksdb {
|
||||
@ -134,4 +135,6 @@ class SyncPoint {
|
||||
rocksdb::SyncPoint::GetInstance()->Process(x + std::to_string(index))
|
||||
#define TEST_SYNC_POINT_CALLBACK(x, y) \
|
||||
rocksdb::SyncPoint::GetInstance()->Process(x, y)
|
||||
#define INIT_SYNC_POINT_SINGLETONS() \
|
||||
(void)rocksdb::SyncPoint::GetInstance();
|
||||
#endif // NDEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user