Skip to content

Commit

Permalink
Flush info log for warning and higher severity (facebook#7462)
Browse files Browse the repository at this point in the history
Summary:
After unclean crash, the tail of the log could look as follows due to block buffering, even when the call to `ROCKSDB_LOG_ERROR()` finished.

```
2020/09/29-13:54:39.596710 7f67025fe700 [ERROR] [/db_impl/db_impl_compaction_flush.cc:2500] Waiting after background compaction err
```

This PR forces the flush while logging warning severity or higher to prevent that case.

Pull Request resolved: facebook#7462

Reviewed By: riversand963

Differential Revision: D24000154

Pulled By: ajkr

fbshipit-source-id: 3bf5f1e69a62ee10e84095cebc88937a8f81b4ad
  • Loading branch information
ajkr authored and facebook-github-bot committed Sep 29, 2020
1 parent 07dc955 commit 1600aac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions env/env.cc
Expand Up @@ -208,6 +208,14 @@ void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap)
kInfoLogLevelNames[log_level], format);
Logv(new_format, ap);
}

if (log_level >= InfoLogLevel::WARN_LEVEL &&
log_level != InfoLogLevel::HEADER_LEVEL) {
// Log messages with severity of warning or higher should be rare and are
// sometimes followed by an unclean crash. We want to be sure important
// messages are not lost in an application buffer when that happens.
Flush();
}
}

static void Logv(const InfoLogLevel log_level, Logger *info_log, const char *format, va_list ap) {
Expand Down

0 comments on commit 1600aac

Please sign in to comment.