Support setting up fail points in config

This commit is contained in:
vdimir 2023-08-31 11:33:52 +00:00
parent 4fa9dcb326
commit b9bb4af6be
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862
3 changed files with 23 additions and 1 deletions

View File

@ -42,6 +42,7 @@
#include <Common/Config/AbstractConfigurationComparison.h>
#include <Common/assertProcessUserMatchesDataOwner.h>
#include <Common/makeSocketAddress.h>
#include <Common/FailPoint.h>
#include <Server/waitServersToFinish.h>
#include <Core/ServerUUID.h>
#include <IO/ReadHelpers.h>
@ -884,6 +885,8 @@ try
}
}
FailPointInjection::enableFromGlobalConfig(config());
int default_oom_score = 0;
#if !defined(NDEBUG)

View File

@ -1,5 +1,6 @@
#include <Common/Exception.h>
#include <Common/FailPoint.h>
#include <Common/Config/ConfigHelper.h>
#include <boost/core/noncopyable.hpp>
#include <chrono>
@ -162,6 +163,21 @@ void FailPointInjection::wait(const String & fail_point_name)
auto ptr = iter->second;
ptr->wait();
}
};
}
void FailPointInjection::enableFromGlobalConfig(const Poco::Util::AbstractConfiguration & config)
{
String root_key = "fail_points_active";
Poco::Util::AbstractConfiguration::Keys tables_keys;
config.keys(root_key, tables_keys);
for (const auto & table_key : tables_keys)
{
if (ConfigHelper::getBool(config, root_key + "." + table_key))
FailPointInjection::enableFailPoint(table_key);
}
}
}

View File

@ -3,6 +3,7 @@
#include <Common/Exception.h>
#include <Core/Types.h>
#include <Poco/Util/AbstractConfiguration.h>
#ifdef __clang__
#pragma clang diagnostic push
@ -46,6 +47,8 @@ public:
static void wait(const String & fail_point_name);
static void enableFromGlobalConfig(const Poco::Util::AbstractConfiguration & config);
private:
static std::mutex mu;
static std::unordered_map<String, std::shared_ptr<FailPointChannel>> fail_point_wait_channels;