@ -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 ( ) ; } ) ;