From 5de6f86c27e4c5e9ea3072f8ffbfbe5702e0055d Mon Sep 17 00:00:00 2001 From: Antonio Andelic Date: Wed, 1 Feb 2023 12:28:44 +0000 Subject: [PATCH] Fix clang-tidy error --- src/Coordination/Changelog.cpp | 27 +++++++++++++++------------ utils/keeper-data-dumper/main.cpp | 3 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Coordination/Changelog.cpp b/src/Coordination/Changelog.cpp index 142a7209b42..00da6f606ca 100644 --- a/src/Coordination/Changelog.cpp +++ b/src/Coordination/Changelog.cpp @@ -157,21 +157,24 @@ public: assert(file_buffer && current_file_description); assert(record.header.index - getStartIndex() <= current_file_description->expectedEntriesCountInLog()); - const bool log_is_complete = record.header.index - getStartIndex() == current_file_description->expectedEntriesCountInLog(); - - if (log_is_complete) - rotate(record.header.index); - - // writing at least 1 log is requirement - we don't want empty log files - // we use count() that can be unreliable for more complex WriteBuffers, so we should be careful if we change the type of it in the future - const bool log_too_big = record.header.index != getStartIndex() && log_file_settings.max_size != 0 - && initial_file_size + file_buffer->count() > log_file_settings.max_size; - - if (log_too_big) + if (const bool log_is_complete = record.header.index - getStartIndex() == current_file_description->expectedEntriesCountInLog(); + log_is_complete) { - LOG_TRACE(log, "Log file reached maximum allowed size ({} bytes), creating new log file", log_file_settings.max_size); rotate(record.header.index); } + else + { + // writing at least 1 log is requirement - we don't want empty log files + // we use count() that can be unreliable for more complex WriteBuffers, so we should be careful if we change the type of it in the future + const bool log_too_big = record.header.index != getStartIndex() && log_file_settings.max_size != 0 + && initial_file_size + file_buffer->count() > log_file_settings.max_size; + + if (log_too_big) + { + LOG_TRACE(log, "Log file reached maximum allowed size ({} bytes), creating new log file", log_file_settings.max_size); + rotate(record.header.index); + } + } if (!prealloc_done) [[unlikely]] { diff --git a/utils/keeper-data-dumper/main.cpp b/utils/keeper-data-dumper/main.cpp index 0ea6371b49f..e82b21079fe 100644 --- a/utils/keeper-data-dumper/main.cpp +++ b/utils/keeper-data-dumper/main.cpp @@ -69,7 +69,8 @@ int main(int argc, char *argv[]) LOG_INFO(logger, "Last committed index: {}", last_commited_index); - DB::KeeperLogStore changelog(argv[2], 10000000, true, settings->compress_logs); + DB::KeeperLogStore changelog( + argv[2], LogFileSettings{.force_sync = true, .compress_logs = settings->compress_logs, .rotate_interval = 10000000}); changelog.init(last_commited_index, 10000000000UL); /// collect all logs if (changelog.size() == 0) LOG_INFO(logger, "Changelog empty");