Skip to content

Commit 7ebb2c3

Browse files
author
Andrzej Religa
committed
Bug#33819386 Router queries similar data twice when refreshing the ClusterSet metadata.
In the current implementation when working with clusterset, some data is queried twice while it could be fetched in a single query. That adds to the metadata refresh execution time. This patch optimizes the metadata query, merging separate queries into a single one. Change-Id: I5dbad25d3b3f580de8899e033c33fea3c4fa6e70
1 parent 33c93c9 commit 7ebb2c3

File tree

13 files changed

+260
-275
lines changed

13 files changed

+260
-275
lines changed

router/src/harness/include/mysql/harness/event_state_tracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class HARNESS_EXPORT EventStateTracker {
5252
MetadataNodeInGR,
5353
GRNodeInMetadata,
5454
TargetClusterPresentInOptions,
55-
TargetClusterInvalidated,
55+
ClusterInvalidatedInMetadata,
5656
ClusterWasBootstrappedAgainstClusterset,
5757
NoRightsToUpdateRouterAttributes
5858
};

router/src/metadata_cache/include/mysqlrouter/metadata_cache_datatypes.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,25 @@ using metadata_servers_list_t = std::vector<metadata_server_t>;
144144
*/
145145
class METADATA_CACHE_EXPORT ManagedCluster {
146146
public:
147+
/** @brief UUID in the metadata */
148+
std::string id;
149+
/** @brief Name of the cluster */
150+
std::string name;
147151
/** @brief List of the members that belong to the cluster */
148152
cluster_nodes_list_t members;
149153
/** @brief Whether the cluster is in single_primary_mode (from PFS in case of
150154
* GR) */
151155
bool single_primary_mode;
152-
/** @brief Id of the view this metadata represents (only used for AR now)*/
153-
uint64_t view_id{0};
154156
/** @brief Metadata for the cluster is not consistent (only applicable for
155157
* the GR cluster when the data in the GR metadata is not consistent with the
156158
* cluster metadata)*/
157159
bool md_discrepancy{false};
158160

161+
/** @brief Is this a PRIMARY Cluster in case of ClusterSet */
162+
bool is_primary{true};
163+
/** @brief Is the Cluster marked as invalid in the metadata */
164+
bool is_invalidated{false};
165+
159166
// address of the writable metadata server that can be used for updating the
160167
// metadata (router version, last_check_in), error code if not found
161168
stdx::expected<metadata_cache::metadata_server_t, std::error_code>
@@ -173,6 +180,10 @@ class METADATA_CACHE_EXPORT ManagedCluster {
173180
struct METADATA_CACHE_EXPORT ClusterTopology {
174181
ManagedCluster cluster_data;
175182
metadata_servers_list_t metadata_servers;
183+
184+
/** @brief Id of the view this metadata represents (used for AR and
185+
* ClusterSets)*/
186+
uint64_t view_id{0};
176187
};
177188

178189
/**

router/src/metadata_cache/src/cluster_metadata_ar.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2019, 2021, Oracle and/or its affiliates.
2+
Copyright (c) 2019, 2022, Oracle and/or its affiliates.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -118,7 +118,7 @@ ARClusterMetadata::fetch_cluster_topology(
118118
result.cluster_data.members = std::move(new_instances);
119119
result.cluster_data.writable_server =
120120
find_rw_server(result.cluster_data.members);
121-
result.cluster_data.view_id = this->view_id_;
121+
result.view_id = this->view_id_;
122122

123123
// for ReplicaSet Cluster we assume metadata servers are just Cluster nodes
124124
for (const auto &cluster_node : result.cluster_data.members) {

0 commit comments

Comments
 (0)