From ba7da434ae003151eb8302fd574d964b3f2a6b3e Mon Sep 17 00:00:00 2001 From: Aaron Gao Date: Tue, 11 Apr 2017 16:53:57 -0700 Subject: [PATCH] fix db_stress crash caused by buggy kernel warning Summary: filter the warning out and only print it once. Closes https://github.com/facebook/rocksdb/pull/2137 Differential Revision: D4870925 Pulled By: lightmark fbshipit-source-id: 91b363ce7f70bce88b0780337f408fc4649139b8 --- env/io_posix.cc | 12 ++++++++---- tools/db_crashtest.py | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/env/io_posix.cc b/env/io_posix.cc index da02951b5..bb3521406 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -772,13 +772,17 @@ Status PosixWritableFile::Close() { fstat(fd_, &file_stats); // After ftruncate, we check whether ftruncate has the correct behavior. // If not, we should hack it with FALLOC_FL_PUNCH_HOLE - if ((file_stats.st_size + file_stats.st_blksize - 1) / + static bool buggy = false; + if (!buggy && (file_stats.st_size + file_stats.st_blksize - 1) / file_stats.st_blksize != file_stats.st_blocks / (file_stats.st_blksize / 512)) { fprintf(stderr, - "Your kernel is buggy (<= 4.0.x) and does not free preallocated" - "blocks on truncate. Hacking around it, but you should upgrade!" - "\n"); + "WARNING: Your kernel is buggy (<= 4.0.x) and does not free" + "preallocated blocks on truncate. Hacking around it, but you" + "should upgrade!\n"); + buggy = true; + } + if (buggy) { IOSTATS_TIMER_GUARD(allocate_nanos); if (allow_fallocate_) { fallocate(fd_, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, filesize_, diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index d28e7a1a2..3333f26c3 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -220,9 +220,10 @@ def blackbox_crash_main(args): while True: line = child.stderr.readline().strip() - if line != '': + if line != '' and not line.startswith('WARNING'): run_had_errors = True - print('***' + line + '^') + print('stderr has error message:') + print('***' + line + '***') else: break