From: Sage Weil Date: Tue, 22 Jun 2021 21:35:10 +0000 (-0400) Subject: mon/LogMonitor: replace semi-broken pending_summary with pending_keys X-Git-Tag: v17.1.0~1423^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=159a9cb04bf4ff78e367cb071551d5b88de2b580;p=ceph.git mon/LogMonitor: replace semi-broken pending_summary with pending_keys 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 --- diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index b9737902cd8d..4325e54d9d98 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -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(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(le.stamp, le)); wait_for_finished_proposal(op, new Monitor::C_Command( mon, op, 0, string(), get_last_committed() + 1)); diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 2be79c4ff44c..1605e67af4bc 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -43,8 +43,8 @@ class LogMonitor : public PaxosService, public md_config_obs_t { private: std::multimap pending_log; - LogSummary pending_summary, summary; - + unordered_set pending_keys; + LogSummary summary; version_t external_log_to = 0; std::map channel_fds;