Skip to content

Commit e57893f

Browse files
Andrzej Religabjornmu
authored andcommitted
Bug#35157953 MySQL Router stops accepting connections - 8.0.32
Post-push fix: Remove the dependency connection -> destination the initial patch introduced to allow cleaner reuse in MCMD component. Change-Id: Ie10bc4a13f077c3eddf3da2b9867ffa0dee76a6c
1 parent 4ebb3c3 commit e57893f

File tree

6 files changed

+97
-36
lines changed

6 files changed

+97
-36
lines changed

router/src/routing/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ ADD_DEPENDENCIES(sql_lexer GenServerSource)
3838
ADD_LIBRARY(routing SHARED
3939
mysql_routing.cc
4040
destination.cc
41+
destination_error.cc
4142
dest_metadata_cache.cc
4243
dest_first_available.cc
4344
dest_next_available.cc

router/src/routing/src/connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "basic_protocol_splicer.h"
3535
#include "context.h"
3636
#include "destination.h" // RouteDestination
37+
#include "destination_error.h"
3738
#include "mysql/harness/net_ts/io_context.h"
3839
#include "mysql/harness/net_ts/timer.h"
3940
#include "mysql/harness/stdx/monitor.h"

router/src/routing/src/destination.cc

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <stdexcept> // out_of_range
3030
#include <system_error>
3131

32+
#include "destination_error.h"
3233
#include "mysqlrouter/routing.h"
3334
#include "tcp_address.h"
3435

@@ -157,27 +158,3 @@ std::optional<Destinations> RouteDestination::refresh_destinations(
157158
const Destinations &) {
158159
return std::nullopt;
159160
}
160-
161-
const std::error_category &destinations_error_category() noexcept {
162-
class destinations_category_impl : public std::error_category {
163-
public:
164-
const char *name() const noexcept override { return "destinations"; }
165-
std::string message(int ev) const override {
166-
switch (static_cast<DestinationsErrc>(ev)) {
167-
case DestinationsErrc::kNotSet:
168-
return "not set";
169-
case DestinationsErrc::kNoDestinations:
170-
return "no destinations";
171-
default:
172-
return "(unrecognized error)";
173-
}
174-
}
175-
};
176-
177-
static destinations_category_impl instance;
178-
return instance;
179-
}
180-
181-
std::error_code make_error_code(DestinationsErrc e) {
182-
return {static_cast<int>(e), destinations_error_category()};
183-
}

router/src/routing/src/destination.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,4 @@ class RouteDestination : public DestinationNodesStateNotifier {
322322
Protocol::Type protocol_;
323323
};
324324

325-
enum class DestinationsErrc {
326-
kNotSet = 1,
327-
kNoDestinations = 2,
328-
};
329-
330-
namespace std {
331-
template <>
332-
struct is_error_code_enum<DestinationsErrc> : true_type {};
333-
} // namespace std
334-
335-
std::error_code make_error_code(DestinationsErrc);
336-
337325
#endif // ROUTING_DESTINATION_INCLUDED
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright (c) 2023, Oracle and/or its affiliates.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License, version 2.0,
6+
as published by the Free Software Foundation.
7+
8+
This program is also distributed with certain software (including
9+
but not limited to OpenSSL) that is licensed under separate terms,
10+
as designated in a particular file or component or in included license
11+
documentation. The authors of MySQL hereby grant you an additional
12+
permission to link the program and your derivative works with the
13+
separately licensed software that they have included with MySQL.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23+
*/
24+
25+
#include "destination_error.h"
26+
27+
#include <string>
28+
29+
const std::error_category &destinations_error_category() noexcept {
30+
class destinations_category_impl : public std::error_category {
31+
public:
32+
const char *name() const noexcept override { return "destinations"; }
33+
std::string message(int ev) const override {
34+
switch (static_cast<DestinationsErrc>(ev)) {
35+
case DestinationsErrc::kNotSet:
36+
return "not set";
37+
case DestinationsErrc::kNoDestinations:
38+
return "no destinations";
39+
default:
40+
return "(unrecognized error)";
41+
}
42+
}
43+
};
44+
45+
static destinations_category_impl instance;
46+
return instance;
47+
}
48+
49+
std::error_code make_error_code(DestinationsErrc e) {
50+
return {static_cast<int>(e), destinations_error_category()};
51+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright (c) 2023, Oracle and/or its affiliates.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License, version 2.0,
6+
as published by the Free Software Foundation.
7+
8+
This program is also distributed with certain software (including
9+
but not limited to OpenSSL) that is licensed under separate terms,
10+
as designated in a particular file or component or in included license
11+
documentation. The authors of MySQL hereby grant you an additional
12+
permission to link the program and your derivative works with the
13+
separately licensed software that they have included with MySQL.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23+
*/
24+
25+
#ifndef ROUTING_DESTINATION_ERROR_INCLUDED
26+
#define ROUTING_DESTINATION_ERROR_INCLUDED
27+
28+
#include <system_error>
29+
#include <vector>
30+
31+
enum class DestinationsErrc {
32+
kNotSet = 1,
33+
kNoDestinations = 2,
34+
};
35+
36+
namespace std {
37+
template <>
38+
struct is_error_code_enum<DestinationsErrc> : true_type {};
39+
} // namespace std
40+
41+
std::error_code make_error_code(DestinationsErrc);
42+
43+
#endif // ROUTING_DESTINATION_ERROR_INCLUDED

0 commit comments

Comments
 (0)