From: Gerald Yang Date: Wed, 3 Mar 2021 04:37:15 +0000 (+0000) Subject: common: reset last_log_sent when clog_to_monitors is updated X-Git-Tag: v14.2.22~29^2~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df1453bc3dadd534ecd2cfcf512c0d668a31a51a;p=ceph.git common: reset last_log_sent when clog_to_monitors is updated When clog_to_monitors is disabled, "last_log" still keeps increasing by get_next_seq() if OSD writes info to clog But "last_log_sent" doesn't increase, if we disable clog_to_monitors for a bit longer and then re-enabling it, the num_unsent could be bigger than log_queue_size(), it will trigger an assertion in _get_mon_log_message We need to reset last_log_sent to last_log before updating clog_to_monitors Signed-off-by: Gerald Yang (cherry picked from commit 294ddf9ba779d40b0bc859e55f5287379c75624f) Conflicts: src/common/LogClient.cc --- diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index f4ac40ee465..17e20094fe1 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -147,7 +147,10 @@ LogClientTemp::~LogClientTemp() void LogChannel::set_log_to_monitors(bool v) { - log_to_monitors = v; + if (log_to_monitors != v) { + parent->reset(); + log_to_monitors = v; + } } void LogChannel::update_config(map &log_to_monitors, @@ -347,6 +350,15 @@ version_t LogClient::queue(LogEntry &entry) return entry.seq; } +void LogClient::reset() +{ + std::lock_guard l(log_lock); + if (log_queue.size()) { + log_queue.clear(); + } + last_log_sent = last_log; +} + uint64_t LogClient::get_next_seq() { std::lock_guard l(log_lock); diff --git a/src/common/LogClient.h b/src/common/LogClient.h index ab3852cae21..e633620e193 100644 --- a/src/common/LogClient.h +++ b/src/common/LogClient.h @@ -251,6 +251,7 @@ public: const EntityName& get_myname(); entity_name_t get_myrank(); version_t queue(LogEntry &entry); + void reset(); private: Message *_get_mon_log_message();