From c7037153c3dcceaf50ba9ba05fee4aaee43f36ce Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Mon, 18 Aug 2014 10:23:18 -0700 Subject: [PATCH] attempt to fix auto_roll_logger_test Summary: auto_roll_logger_test fails from time to time. I wasn't able to repro the issue but by looking at the code, it seems like the initial ctime_ value can be set to the boundary of the second so it may still have a chance to get rolled when interval is set to 1 second. ``` util/auto_roll_logger_test.cc:120: failed: 118 > 708 ==19470== Syscall param msync(start) points to unaddressable byte(s) ==19470== at 0x4E46CE0: __msync_nocancel (in /usr/local/fbcode/gcc-4.8.1-glibc-2.17/lib/libpthread-2.17.so) ==19470== by 0x584EFB: access_mem (Ginit.c:137) ==19470== by 0x5834E3: _ULx86_64_access_reg (libunwind_i.h:162) ==19470== by 0x585601: apply_reg_state (Gparser.c:742) ==19470== by 0x5866BE: _ULx86_64_dwarf_find_save_locs (Gparser.c:883) ==19470== by 0x584550: _ULx86_64_dwarf_step (Gstep.c:34) ==19470== by 0x583653: _ULx86_64_step (Gstep.c:71) ==19470== by 0x583FD2: _ULx86_64_tdep_trace (Gtrace.c:217) ==19470== by 0x5831C3: backtrace (backtrace.c:69) Test Plan: ./auto_roll_logger_test Reviewers: sdong, yhchiang, igor Reviewed By: igor Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D21951 --- util/auto_roll_logger_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/auto_roll_logger_test.cc b/util/auto_roll_logger_test.cc index c8ec459cf..366ca084e 100755 --- a/util/auto_roll_logger_test.cc +++ b/util/auto_roll_logger_test.cc @@ -145,13 +145,13 @@ TEST(AutoRollLoggerTest, RollLogFileBySize) { } TEST(AutoRollLoggerTest, RollLogFileByTime) { - size_t time = 1; + size_t time = 2; size_t log_size = 1024 * 5; InitTestDb(); // -- Test the existence of file during the server restart. ASSERT_TRUE(!env->FileExists(kLogFile)); - AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, 1); + AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, time); ASSERT_TRUE(env->FileExists(kLogFile)); RollLogFileByTimeTest(&logger, time, kSampleMessage + ":RollLogFileByTime"); @@ -184,7 +184,7 @@ TEST(AutoRollLoggerTest, } TEST(AutoRollLoggerTest, CompositeRollByTimeAndSizeLogger) { - size_t time = 1, log_max_size = 1024 * 5; + size_t time = 2, log_max_size = 1024 * 5; InitTestDb(); @@ -222,7 +222,7 @@ TEST(AutoRollLoggerTest, CreateLoggerFromOptions) { // Only roll by Time InitTestDb(); options.max_log_file_size = 0; - options.log_file_time_to_roll = 1; + options.log_file_time_to_roll = 2; ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger)); auto_roll_logger = dynamic_cast(logger.get()); @@ -233,7 +233,7 @@ TEST(AutoRollLoggerTest, CreateLoggerFromOptions) { // roll by both Time and size InitTestDb(); options.max_log_file_size = 1024 * 5; - options.log_file_time_to_roll = 1; + options.log_file_time_to_roll = 2; ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger)); auto_roll_logger = dynamic_cast(logger.get());