mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-29 09:36:17 +00:00
Cleanup auto-roll logger flush-while-rolling test
Summary: Use @omegaga's awesome feature to avoid use of callbacks for ensuring SyncPoints happen in a particular thread. Depends on D60375. Test Plan: $ ./auto_roll_logger_test Reviewers: omegaga, sdong Reviewed By: sdong Subscribers: andrewkr, dhruba, omegaga, leveldb Differential Revision: https://reviews.facebook.net/D60471
This commit is contained in:
parent
cd4178a015
commit
e1b3ee8a79
|
@ -273,35 +273,24 @@ TEST_F(AutoRollLoggerTest, LogFlushWhileRolling) {
|
||||||
ASSERT_TRUE(auto_roll_logger);
|
ASSERT_TRUE(auto_roll_logger);
|
||||||
std::thread flush_thread;
|
std::thread flush_thread;
|
||||||
|
|
||||||
rocksdb::SyncPoint::GetInstance()->LoadDependency({
|
// Notes:
|
||||||
// Need to pin the old logger before beginning the roll, as rolling grabs
|
// (1) Need to pin the old logger before beginning the roll, as rolling grabs
|
||||||
// the mutex, which would prevent us from accessing the old logger.
|
// the mutex, which would prevent us from accessing the old logger. This
|
||||||
{"AutoRollLogger::Flush:PinnedLogger",
|
// also marks flush_thread with AutoRollLogger::Flush:PinnedLogger.
|
||||||
"AutoRollLoggerTest::LogFlushWhileRolling:PreRollAndPostThreadInit"},
|
// (2) Need to reset logger during PosixLogger::Flush() to exercise a race
|
||||||
// Need to finish the flush thread init before this callback because the
|
// condition case, which is executing the flush with the pinned (old)
|
||||||
// callback accesses flush_thread.get_id() in order to apply certain sync
|
// logger after auto-roll logger has cut over to a new logger.
|
||||||
// points only to the flush thread.
|
// (3) PosixLogger::Flush() happens in both threads but its SyncPoints only
|
||||||
{"AutoRollLoggerTest::LogFlushWhileRolling:PreRollAndPostThreadInit",
|
// are enabled in flush_thread (the one pinning the old logger).
|
||||||
"AutoRollLoggerTest::LogFlushWhileRolling:FlushCallbackBegin"},
|
rocksdb::SyncPoint::GetInstance()->LoadDependencyAndMarkers(
|
||||||
// Need to reset logger at this point in Flush() to exercise a race
|
{{"AutoRollLogger::Flush:PinnedLogger",
|
||||||
// condition case, which is executing the flush with the pinned (old)
|
"AutoRollLoggerTest::LogFlushWhileRolling:PreRollAndPostThreadInit"},
|
||||||
// logger after the roll has cut over to a new logger.
|
{"PosixLogger::Flush:Begin1",
|
||||||
{"AutoRollLoggerTest::LogFlushWhileRolling:FlushCallback1",
|
"AutoRollLogger::ResetLogger:BeforeNewLogger"},
|
||||||
"AutoRollLogger::ResetLogger:BeforeNewLogger"},
|
{"AutoRollLogger::ResetLogger:AfterNewLogger",
|
||||||
{"AutoRollLogger::ResetLogger:AfterNewLogger",
|
"PosixLogger::Flush:Begin2"}},
|
||||||
"AutoRollLoggerTest::LogFlushWhileRolling:FlushCallback2"},
|
{{"AutoRollLogger::Flush:PinnedLogger", "PosixLogger::Flush:Begin1"},
|
||||||
});
|
{"AutoRollLogger::Flush:PinnedLogger", "PosixLogger::Flush:Begin2"}});
|
||||||
rocksdb::SyncPoint::GetInstance()->SetCallBack(
|
|
||||||
"PosixLogger::Flush:BeginCallback", [&](void* arg) {
|
|
||||||
TEST_SYNC_POINT(
|
|
||||||
"AutoRollLoggerTest::LogFlushWhileRolling:FlushCallbackBegin");
|
|
||||||
if (std::this_thread::get_id() == flush_thread.get_id()) {
|
|
||||||
TEST_SYNC_POINT(
|
|
||||||
"AutoRollLoggerTest::LogFlushWhileRolling:FlushCallback1");
|
|
||||||
TEST_SYNC_POINT(
|
|
||||||
"AutoRollLoggerTest::LogFlushWhileRolling:FlushCallback2");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
|
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
|
||||||
|
|
||||||
flush_thread = std::thread([&]() { auto_roll_logger->Flush(); });
|
flush_thread = std::thread([&]() { auto_roll_logger->Flush(); });
|
||||||
|
|
|
@ -55,7 +55,8 @@ class PosixLogger : public Logger {
|
||||||
fclose(file_);
|
fclose(file_);
|
||||||
}
|
}
|
||||||
virtual void Flush() override {
|
virtual void Flush() override {
|
||||||
TEST_SYNC_POINT_CALLBACK("PosixLogger::Flush:BeginCallback", nullptr);
|
TEST_SYNC_POINT("PosixLogger::Flush:Begin1");
|
||||||
|
TEST_SYNC_POINT("PosixLogger::Flush:Begin2");
|
||||||
if (flush_pending_) {
|
if (flush_pending_) {
|
||||||
flush_pending_ = false;
|
flush_pending_ = false;
|
||||||
fflush(file_);
|
fflush(file_);
|
||||||
|
|
Loading…
Reference in a new issue