]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/LogMonitor: replace semi-broken pending_summary with pending_keys
authorSage Weil <sage@newdream.net>
Tue, 22 Jun 2021 21:35:10 +0000 (17:35 -0400)
committerSage Weil <sage@newdream.net>
Fri, 2 Jul 2021 13:00:03 +0000 (09:00 -0400)
First, we don't need to store actual keys in pending_summary.  That is
what pending_log contains (the actual pending entries).

However, we do want to efficiently track pending_keys so that we ignore
dups within the same proposal interval.  Use pending_keys for that.

Fix a few users to look only and summary.keys or both summary and
pending_keys, as appropriate.

This is simpler, less confusing, and probably fixes some very subtle
bugs.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/LogMonitor.cc
src/mon/LogMonitor.h

index b9737902cd8d0f09c698eb191440e85dee1fbb3e..4325e54d9d98ebe213f49430dbc9b8bbc0f6e7e2 100644 (file)
@@ -429,8 +429,8 @@ void LogMonitor::log_external_backlog()
 void LogMonitor::create_pending()
 {
   pending_log.clear();
-  pending_summary = summary;
   dout(10) << "create_pending v " << (get_last_committed() + 1) << dendl;
+  pending_keys.clear();
 }
 
 void LogMonitor::encode_pending(MonitorDBStore::TransactionRef t)
@@ -536,7 +536,7 @@ bool LogMonitor::preprocess_log(MonOpRequestRef op)
   for (auto p = m->entries.begin();
        p != m->entries.end();
        ++p) {
-    if (!pending_summary.contains(p->key()))
+    if (!summary.contains(p->key()))
       num_new++;
   }
   if (!num_new) {
@@ -579,12 +579,12 @@ bool LogMonitor::prepare_log(MonOpRequestRef op)
        p != m->entries.end();
        ++p) {
     dout(10) << " logging " << *p << dendl;
-    if (!pending_summary.contains(p->key())) {
-      pending_summary.add(*p);
+    if (!summary.contains(p->key()) &&
+       !pending_keys.count(p->key())) {
+      pending_keys.insert(p->key());
       pending_log.insert(pair<utime_t,LogEntry>(p->stamp, *p));
     }
   }
-  pending_summary.prune(g_conf()->mon_log_max_summary);
   wait_for_finished_proposal(op, new C_Log(this, op));
   return true;
 }
@@ -797,8 +797,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op)
     le.prio = LogEntry::str_to_level(level_str);
     le.channel = CLOG_CHANNEL_DEFAULT;
     le.msg = str_join(logtext, " ");
-    pending_summary.add(le);
-    pending_summary.prune(g_conf()->mon_log_max_summary);
+    pending_keys.insert(le.key());
     pending_log.insert(pair<utime_t,LogEntry>(le.stamp, le));
     wait_for_finished_proposal(op, new Monitor::C_Command(
           mon, op, 0, string(), get_last_committed() + 1));
index 2be79c4ff44c9b607f1d55558ce30b83f1de7aff..1605e67af4bc84ff99e06bf7a1aeb6da5b494709 100644 (file)
@@ -43,8 +43,8 @@ class LogMonitor : public PaxosService,
                    public md_config_obs_t {
 private:
   std::multimap<utime_t,LogEntry> pending_log;
-  LogSummary pending_summary, summary;
-
+  unordered_set<LogEntryKey> pending_keys;
+  LogSummary summary;
   version_t external_log_to = 0;
   std::map<std::string, int> channel_fds;