]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: Make log_max_recent have an effect again. 48311/head
authorJoshua Baergen <jbaergen@digitalocean.com>
Thu, 16 Jun 2022 16:14:12 +0000 (10:14 -0600)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Fri, 12 Jan 2024 12:14:50 +0000 (19:14 +0700)
The log improvements in a747aeac13daf3dba43343120659e802cb569f6b
unfortunately left log_max_recent broken because m_max_recent wasn't
used anymore.

Eliminate m_max_recent and set the capacity of the m_recent ring buffer
when log_max_recent changes. In order to call set_capacity(),
ConcreteEntry needed its move constructor set noexcept.

I haven't followed the boost code all the way down but I suspect that
setting the ring buffer capacity to anything less than 1 entry will
probably cause problems, so restrict log_max_recent to >=1.

Also fix a wrong variable used for printing the max new entries during
"log dump".

Signed-off-by: Joshua Baergen <jbaergen@digitalocean.com>
(cherry picked from commit 3d59ba1671e3e76326fb706a76b8d9638d782924)

Conflicts:
  - file: src/common/options/global.yaml.in
    desc: file not exists in pacific
  - file: src/common/options.cc
    desc: added 'set_min' for log_max_recent

src/common/options.cc
src/log/Entry.h
src/log/Log.cc
src/log/Log.h

index c9cb4b8d75f458ab2a56d315a78095139d229e66..d3f0166ffb1894704b37f8b7e8727deefc66e675 100644 (file)
@@ -597,6 +597,7 @@ std::vector<Option> get_global_options() {
     Option("log_max_recent", Option::TYPE_INT, Option::LEVEL_ADVANCED)
     .set_default(500)
     .set_daemon_default(10000)
+    .set_min(1)
     .set_description("recent log entries to keep in memory to dump in the event of a crash")
     .set_long_description("The purpose of this option is to log at a higher debug level only to the in-memory buffer, and write out the detailed log messages only if there is a crash.  Only log entries below the lower log level will be written unconditionally to the log.  For example, debug_osd=1/5 will write everything <= 1 to the log unconditionally but keep entries at levels 2-5 in memory.  If there is a seg fault or assertion failure, all entries will be dumped to the log."),
 
index 536f1a9dc8a223956c3450545484794eb739b154..3677c8eb9518040644ae3b95ed253561e23fc78a 100644 (file)
@@ -90,7 +90,7 @@ public:
     str.assign(strv.begin(), strv.end());
     return *this;
   }
-  ConcreteEntry(ConcreteEntry&& e) : Entry(e), str(std::move(e.str)) {}
+  ConcreteEntry(ConcreteEntry&& e) noexcept : Entry(e), str(std::move(e.str)) {}
   ConcreteEntry& operator=(ConcreteEntry&& e) {
     Entry::operator=(e);
     str = std::move(e.str);
index f57f01adde0c0a3dca31126bbf2863ba524896e7..75629cdee12020b2973492f51ea954502be0f0c9 100644 (file)
@@ -132,7 +132,7 @@ void Log::set_max_new(std::size_t n)
 void Log::set_max_recent(std::size_t n)
 {
   std::scoped_lock lock(m_flush_mutex);
-  m_max_recent = n;
+  m_recent.set_capacity(n);
 }
 
 void Log::set_log_file(std::string_view fn)
@@ -490,8 +490,8 @@ void Log::dump_recent()
                             tid_to_int(pthread_id), pthread_name), true);
   }
 
-  _log_message(fmt::format("  max_recent {:9}", m_max_recent), true);
-  _log_message(fmt::format("  max_new    {:9}", m_max_recent), true);
+  _log_message(fmt::format("  max_recent {:9}", m_recent.capacity()), true);
+  _log_message(fmt::format("  max_new    {:9}", m_max_new), true);
   _log_message(fmt::format("  log_file {}", m_log_file), true);
 
   _log_message("--- end dump of recent events ---", true);
index ce81b2fde59ddd66dcdf787b23b9561e142f33e8..6ec8b55757c270400725e87e96d0b3067a6cc02c 100644 (file)
@@ -116,7 +116,6 @@ private:
   bool m_stop = false;
 
   std::size_t m_max_new = DEFAULT_MAX_NEW;
-  std::size_t m_max_recent = DEFAULT_MAX_RECENT;
 
   bool m_inject_segv = false;