]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: reset last_log_sent when clog_to_monitors is updated 39935/head
authorGerald Yang <gerald.yang@canonical.com>
Wed, 3 Mar 2021 04:37:15 +0000 (04:37 +0000)
committerGerald Yang <gerald.yang@canonical.com>
Mon, 8 Mar 2021 08:19:58 +0000 (16:19 +0800)
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 <gerald.yang@canonical.com>
src/common/LogClient.cc
src/common/LogClient.h

index c2354927b41d992c14d9c4ca3244b0a56ca51e81..4d28f4232ce3d11fa18283cf9b5c23b10f996b20 100644 (file)
@@ -128,8 +128,12 @@ LogClient::LogClient(CephContext *cct, Messenger *m, MonMap *mm,
 {
 }
 
-void LogChannel::set_log_to_monitors(bool v) {
-  log_to_monitors = v;
+void LogChannel::set_log_to_monitors(bool v)
+{
+  if (log_to_monitors != v) {
+    parent->reset();
+    log_to_monitors = v;
+  }
 }
 
 void LogChannel::update_config(map<string,string> &log_to_monitors,
@@ -327,6 +331,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);
index f4ed31fdbee3de5a2d2b45ed2bde2f7f601f6ed9..c20fde4f157d67b6d34681742e099680d68940b3 100644 (file)
@@ -232,6 +232,7 @@ public:
   const EntityName& get_myname();
   entity_name_t get_myrank();
   version_t queue(LogEntry &entry);
+  void reset();
 
 private:
   ceph::ref_t<Message> _get_mon_log_message();