mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-23 10:10:50 +00:00
log nodes update in cluster discovery
This commit is contained in:
parent
a2d37fe2ed
commit
76170156ef
@ -148,7 +148,34 @@ bool ClusterDiscovery::needUpdate(const Strings & node_uuids, const NodesInfo &
|
|||||||
{
|
{
|
||||||
bool has_difference = node_uuids.size() != nodes.size() ||
|
bool has_difference = node_uuids.size() != nodes.size() ||
|
||||||
std::any_of(node_uuids.begin(), node_uuids.end(), [&nodes] (auto u) { return !nodes.contains(u); });
|
std::any_of(node_uuids.begin(), node_uuids.end(), [&nodes] (auto u) { return !nodes.contains(u); });
|
||||||
|
UNUSED(log);
|
||||||
|
#if defined(NDEBUG) || defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || defined(UNDEFINED_BEHAVIOR_SANITIZER)
|
||||||
|
{
|
||||||
|
/// Just to log updated nodes, suboptimal, but should be ok for expected update sizes.
|
||||||
|
/// Disabled on release build.
|
||||||
|
std::set<String> new_names(node_uuids.begin(), node_uuids.end());
|
||||||
|
std::set<String> old_names;
|
||||||
|
for (const auto & [name, _] : nodes)
|
||||||
|
old_names.emplace(name);
|
||||||
|
|
||||||
|
auto format_cluster_update = [](const std::set<String> & s1, const std::set<String> & s2)
|
||||||
|
{
|
||||||
|
std::vector<String> diff;
|
||||||
|
std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(), std::back_inserter(diff));
|
||||||
|
|
||||||
|
constexpr size_t max_to_show = 3;
|
||||||
|
size_t sz = diff.size();
|
||||||
|
if (sz > max_to_show)
|
||||||
|
diff.resize(max_to_show);
|
||||||
|
return fmt::format("{} nodes ({}{})", sz, fmt::join(diff, ", "), diff.size() == sz ? "" : ",...");
|
||||||
|
};
|
||||||
|
|
||||||
|
LOG_DEBUG(log, "Cluster update: added: {}, removed: {}",
|
||||||
|
format_cluster_update(new_names, old_names),
|
||||||
|
format_cluster_update(old_names, new_names));
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return has_difference;
|
return has_difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
|
|
||||||
ClusterPtr getCluster(const ClusterInfo & cluster_info);
|
ClusterPtr getCluster(const ClusterInfo & cluster_info);
|
||||||
|
|
||||||
static bool needUpdate(const Strings & node_uuids, const NodesInfo & nodes);
|
bool needUpdate(const Strings & node_uuids, const NodesInfo & nodes);
|
||||||
bool updateCluster(const String & cluster_name);
|
bool updateCluster(const String & cluster_name);
|
||||||
bool updateCluster(ClusterInfo & cluster_info);
|
bool updateCluster(ClusterInfo & cluster_info);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user