Merge pull request #64259 from ClickHouse/backport/24.3/64218

Backport #64218 to 24.3: Ignore `text_log` for Keeper
This commit is contained in:
Antonio Andelic 2024-05-24 09:30:22 +02:00 committed by GitHub
commit ca8aa07ca5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 6 deletions

View File

@ -182,6 +182,11 @@ std::string Keeper::getDefaultConfigFileName() const
return "keeper_config.xml";
}
bool Keeper::allowTextLog() const
{
return false;
}
void Keeper::handleCustomArguments(const std::string & arg, [[maybe_unused]] const std::string & value) // NOLINT
{
if (arg == "force-recovery")

View File

@ -65,6 +65,8 @@ protected:
std::string getDefaultConfigFileName() const override;
bool allowTextLog() const override;
private:
Poco::Net::SocketAddress socketBindListen(Poco::Net::ServerSocket & socket, const std::string & host, UInt16 port, [[maybe_unused]] bool secure = false) const;

View File

@ -270,7 +270,7 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
}
}
#ifndef WITHOUT_TEXT_LOG
if (config.has("text_log"))
if (allowTextLog() && config.has("text_log"))
{
String text_log_level_str = config.getString("text_log.level", "trace");
int text_log_level = Poco::Logger::parseLevel(text_log_level_str);

View File

@ -23,6 +23,10 @@ public:
/// Close log files. On next log write files will be reopened.
void closeLogs(Poco::Logger & logger);
virtual ~Loggers() = default;
protected:
virtual bool allowTextLog() const { return true; }
private:
Poco::AutoPtr<Poco::FileChannel> log_file;

View File

@ -107,6 +107,10 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
[[maybe_unused]] bool push_result = logs_queue->emplace(std::move(columns));
}
auto text_log_locked = text_log.lock();
if (!text_log_locked)
return;
/// Also log to system.text_log table, if message is not too noisy
auto text_log_max_priority_loaded = text_log_max_priority.load(std::memory_order_relaxed);
if (text_log_max_priority_loaded && msg.getPriority() <= text_log_max_priority_loaded)
@ -131,10 +135,7 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
elem.source_line = msg.getSourceLine();
elem.message_format_string = msg.getFormatString();
std::shared_ptr<SystemLogQueue<TextLogElement>> text_log_locked{};
text_log_locked = text_log.lock();
if (text_log_locked)
text_log_locked->push(std::move(elem));
text_log_locked->push(std::move(elem));
}
#endif
}

View File

@ -1,7 +1,6 @@
#pragma once
#include <atomic>
#include <vector>
#include <map>
#include <Poco/AutoPtr.h>
#include <Poco/Channel.h>