26#ifndef MYSQLROUTER_UNREACHABLE_DESTINATIONS_QUARANTINE_INCLUDED
27#define MYSQLROUTER_UNREACHABLE_DESTINATIONS_QUARANTINE_INCLUDED
67 uint32_t qurantine_threshold);
133 const std::string &instance_name,
const bool nodes_changed_on_md_refresh,
134 const std::vector<AvailableDestination> &available_destinations);
207 std::vector<std::string> referencing_instances,
209 std::function<
void()> on_delete, std::function<
void()> on_connect_ok)
275 std::vector<std::shared_ptr<Unreachable_destination_candidate>>
static IoComponent & get_instance()
Definition: io_component.cc:147
net::io_context & io_context()
get ref to the io_context.
Definition: io_component.cc:58
Information about unreachable destination candidates that is shared between plugin instances.
Definition: unreachable_destinations_quarantine.h:49
std::map< mysql_harness::TCPAddress, uint32_t > destination_errors_
Definition: unreachable_destinations_quarantine.h:277
QuarantineRoutingCallbacks routing_callbacks_
Definition: unreachable_destinations_quarantine.h:289
void quarantine_handler(const std::error_code &ec, const mysql_harness::TCPAddress &dest)
Async handler responsible of periodic checks for destination candidate availability.
Definition: unreachable_destinations_quarantine.cc:190
std::vector< std::string > get_referencing_routing_instances(const mysql_harness::TCPAddress &destination)
For a given destination get names of all routing instances that references it.
Definition: unreachable_destinations_quarantine.cc:280
void add_destination_candidate_to_quarantine(const mysql_harness::TCPAddress &dest)
Definition: unreachable_destinations_quarantine.cc:75
std::atomic< bool > stopped_
Definition: unreachable_destinations_quarantine.h:282
void register_route(const std::string &route_name)
Definition: unreachable_destinations_quarantine.cc:43
void drop_stray_destinations(const std::string &instance_name, const AllowedNodes &routing_new_destinations)
If destination list of a routing instance has changed it is possible that some destinations are no lo...
Definition: unreachable_destinations_quarantine.cc:312
std::chrono::seconds quarantine_interval_
Definition: unreachable_destinations_quarantine.h:271
void remove_destination_candidate_from_quarantine(const mysql_harness::TCPAddress &dest)
Remove unreachable destination candidate from quarantine.
Definition: unreachable_destinations_quarantine.cc:118
uint32_t quarantine_threshold_
Definition: unreachable_destinations_quarantine.h:272
void init(std::chrono::seconds quarantine_interval, uint32_t qurantine_threshold)
Initialize the unreachable destination candidate mechanism.
Definition: unreachable_destinations_quarantine.cc:49
net::io_context & io_ctx_
Definition: unreachable_destinations_quarantine.h:273
bool is_quarantined(const mysql_harness::TCPAddress &dest)
Query the quarantined destination candidates set and check if the given destination candidate is quar...
Definition: unreachable_destinations_quarantine.cc:146
std::atomic< size_t > quarantined_dest_counter_
number of quarantined destinations
Definition: unreachable_destinations_quarantine.h:285
std::condition_variable quarantine_empty_cond_
Definition: unreachable_destinations_quarantine.h:286
std::vector< std::shared_ptr< Unreachable_destination_candidate > > quarantined_destination_candidates_
Definition: unreachable_destinations_quarantine.h:276
std::mutex destination_errors_mutex_
Definition: unreachable_destinations_quarantine.h:278
void stop_quarantine()
Stop all async operations and clear the quarantine list.
Definition: unreachable_destinations_quarantine.cc:166
std::mutex quarantine_mutex_
Definition: unreachable_destinations_quarantine.h:274
void stop_socket_acceptors_on_all_nodes_quarantined()
Go through all routing instances and check if there are routing plugins which have all destination ca...
Definition: unreachable_destinations_quarantine.cc:265
std::vector< std::string > routing_instances_
Definition: unreachable_destinations_quarantine.h:281
void unregister_routing_callbacks()
Definition: unreachable_destinations_quarantine.cc:38
void refresh_quarantine(const std::string &instance_name, const bool nodes_changed_on_md_refresh, const std::vector< AvailableDestination > &available_destinations)
Refresh the quarantined destination candidates list on metadata refresh.
Definition: unreachable_destinations_quarantine.cc:156
void update_destinations_state(const AllowedNodes &destination_list)
On metadata refresh we got a destination candidates list that is reported to be available (from the m...
Definition: unreachable_destinations_quarantine.cc:296
std::mutex unreachable_destinations_init_mutex_
Definition: unreachable_destinations_quarantine.h:279
std::mutex quarantine_empty_cond_m_
Definition: unreachable_destinations_quarantine.h:287
std::mutex routing_instances_mutex_
Definition: unreachable_destinations_quarantine.h:280
void register_routing_callbacks(QuarantineRoutingCallbacks &&routing_callbacks)
Definition: unreachable_destinations_quarantine.cc:32
std::chrono::milliseconds kQuarantinedConnectTimeout
Definition: unreachable_destinations_quarantine.h:270
bool report_connection_result(const mysql_harness::TCPAddress &dest, bool success)
Register the connection error or success to a given destination.
Definition: unreachable_destinations_quarantine.cc:55
Defines an IP address with port number
Definition: tcp_address.h:40
Definition: socket.h:1144
Definition: io_context.h:61
Definition: internet.h:678
Definition: internet.h:542
const_iterator iterator
Definition: internet.h:550
TCP protocol.
Definition: internet.h:1155
Definition: expected.h:944
std::vector< AvailableDestination > AllowedNodes
Definition: destination_status_types.h:59
std::error_code make_error_code(DynamicLoaderErrc ec)
make error_code from a DynamicLoaderErrc.
Definition: dynamic_loader.cc:79
Definition: gcs_xcom_synode.h:64
Definition: destination_status_types.h:34
Class representing a single entry (destination) in quarantined destination set.
Definition: unreachable_destinations_quarantine.h:204
bool connect_timed_out_
Definition: unreachable_destinations_quarantine.h:253
std::vector< std::string > referencing_routing_instances_
Definition: unreachable_destinations_quarantine.h:242
bool connected_
Definition: unreachable_destinations_quarantine.h:254
net::io_context * io_ctx_
Definition: unreachable_destinations_quarantine.h:240
Function
Definition: unreachable_destinations_quarantine.h:256
net::ip::tcp::resolver::results_type endpoints_
Definition: unreachable_destinations_quarantine.h:248
stdx::expected< void, std::error_code > connected()
Definition: unreachable_destinations_quarantine.cc:497
net::steady_timer timer_
Definition: unreachable_destinations_quarantine.h:244
std::function< void()> on_delete_
Definition: unreachable_destinations_quarantine.h:266
Unreachable_destination_candidate & operator=(const Unreachable_destination_candidate &)=delete
std::error_code last_ec_
Definition: unreachable_destinations_quarantine.h:263
server_protocol_type::socket server_sock_
Definition: unreachable_destinations_quarantine.h:250
net::ip::tcp::resolver::results_type::iterator endpoints_it_
Definition: unreachable_destinations_quarantine.h:249
Unreachable_destination_candidate(const Unreachable_destination_candidate &)=delete
Function func_
Definition: unreachable_destinations_quarantine.h:261
stdx::expected< void, std::error_code > connect_finish()
Definition: unreachable_destinations_quarantine.cc:463
server_protocol_type::endpoint server_endpoint_
Definition: unreachable_destinations_quarantine.h:251
stdx::expected< void, std::error_code > resolve()
Definition: unreachable_destinations_quarantine.cc:385
stdx::expected< void, std::error_code > connect()
Definition: unreachable_destinations_quarantine.cc:362
stdx::expected< void, std::error_code > connect_init()
Definition: unreachable_destinations_quarantine.cc:407
stdx::expected< void, std::error_code > try_connect()
Definition: unreachable_destinations_quarantine.cc:418
Unreachable_destination_candidate & operator=(Unreachable_destination_candidate &&)=default
std::chrono::seconds quarantine_interval_
Definition: unreachable_destinations_quarantine.h:243
Unreachable_destination_candidate(Unreachable_destination_candidate &&)=default
Unreachable_destination_candidate(net::io_context *io_ctx, const mysql_harness::TCPAddress &addr, std::vector< std::string > referencing_instances, std::chrono::seconds quarantine_interval, std::function< void()> on_delete, std::function< void()> on_connect_ok)
Definition: unreachable_destinations_quarantine.h:205
std::function< void()> on_connect_ok_
Definition: unreachable_destinations_quarantine.h:267
stdx::expected< void, std::error_code > init_endpoint()
Definition: unreachable_destinations_quarantine.cc:400
stdx::expected< void, std::error_code > next_endpoint()
Definition: unreachable_destinations_quarantine.cc:452
~Unreachable_destination_candidate()
Definition: unreachable_destinations_quarantine.cc:353
mysql_harness::TCPAddress address_
Definition: unreachable_destinations_quarantine.h:241
double seconds()
Definition: task.cc:310