Skip to content

Commit 4d4be52

Browse files
author
Andrzej Religa
committed
Bug#35705590 Router crashes when target is clusterset and only has access to no-quorum part.
New tests for "WL#15841 Option to allow traffic when the sole reachable partition has no quorum" revealed a legacy issue where the Router crashes if the target Cluster of the Router is part of a ClusterSet and the Router only has an access to the sub-group of this cluster with no GR quorum. The problem is the access to std::optional<> member without checking it is set, which happens in case of Router having only access to no-quorum group. This patch fixes the issue checking if the optional value is set before accessing it. This scenario is tested by WL#15841 test ClusterSetAccessToPartitionWithNoQuorum. Change-Id: I90b3400ed5e08e03699dbb6d252755cfc93ad75f
1 parent cc4bdeb commit 4d4be52

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

router/src/metadata_cache/src/cluster_metadata_gr.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,17 +1344,19 @@ static std::optional<size_t> target_cluster_pos(
13441344

13451345
std::optional<metadata_cache::metadata_server_t>
13461346
GRClusterSetMetadataBackend::find_rw_server() {
1347-
for (auto &cluster : (*cluster_topology_).clusters_data) {
1348-
if (!cluster.is_primary) continue;
1347+
if (cluster_topology_) {
1348+
for (auto &cluster : (*cluster_topology_).clusters_data) {
1349+
if (!cluster.is_primary) continue;
13491350

1350-
log_debug("Updating the status of cluster '%s' to find the writable node",
1351-
cluster.name.c_str());
1351+
log_debug("Updating the status of cluster '%s' to find the writable node",
1352+
cluster.name.c_str());
13521353

1353-
// we need to connect to the Primary Cluster and query its GR status to
1354-
// figure out the current Primary node
1355-
metadata_->update_cluster_status(cluster);
1354+
// we need to connect to the Primary Cluster and query its GR status to
1355+
// figure out the current Primary node
1356+
metadata_->update_cluster_status(cluster);
13561357

1357-
return metadata_->find_rw_server(cluster.members);
1358+
return metadata_->find_rw_server(cluster.members);
1359+
}
13581360
}
13591361

13601362
return std::nullopt;

0 commit comments

Comments
 (0)