26#ifndef MYSQLROUTER_UNREACHABLE_DESTINATIONS_QUARANTINE_INCLUDED
27#define MYSQLROUTER_UNREACHABLE_DESTINATIONS_QUARANTINE_INCLUDED
67 uint32_t qurantine_threshold);
131 const std::string &instance_name,
const bool nodes_changed_on_md_refresh,
132 const std::vector<AvailableDestination> &available_destinations);
205 std::vector<std::string> referencing_instances,
207 std::function<
void()> on_delete, std::function<
void()> on_connect_ok)
273 std::vector<std::shared_ptr<Unreachable_destination_candidate>>
static IoComponent & get_instance()
Definition: io_component.cc:146
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:275
QuarantineRoutingCallbacks routing_callbacks_
Definition: unreachable_destinations_quarantine.h:287
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:191
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:281
void add_destination_candidate_to_quarantine(const mysql_harness::TCPAddress &dest)
Definition: unreachable_destinations_quarantine.cc:76
std::atomic< bool > stopped_
Definition: unreachable_destinations_quarantine.h:280
void register_route(const std::string &route_name)
Definition: unreachable_destinations_quarantine.cc:44
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:313
std::chrono::seconds quarantine_interval_
Definition: unreachable_destinations_quarantine.h:269
void remove_destination_candidate_from_quarantine(const mysql_harness::TCPAddress &dest)
Remove unreachable destination candidate from quarantine.
Definition: unreachable_destinations_quarantine.cc:119
uint32_t quarantine_threshold_
Definition: unreachable_destinations_quarantine.h:270
void init(std::chrono::seconds quarantine_interval, uint32_t qurantine_threshold)
Initialize the unreachable destination candidate mechanism.
Definition: unreachable_destinations_quarantine.cc:50
net::io_context & io_ctx_
Definition: unreachable_destinations_quarantine.h:271
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:147
std::atomic< size_t > quarantined_dest_counter_
number of quarantined destinations
Definition: unreachable_destinations_quarantine.h:283
std::condition_variable quarantine_empty_cond_
Definition: unreachable_destinations_quarantine.h:284
std::vector< std::shared_ptr< Unreachable_destination_candidate > > quarantined_destination_candidates_
Definition: unreachable_destinations_quarantine.h:274
std::mutex destination_errors_mutex_
Definition: unreachable_destinations_quarantine.h:276
void stop_quarantine()
Stop all async operations and clear the quarantine list.
Definition: unreachable_destinations_quarantine.cc:167
std::mutex quarantine_mutex_
Definition: unreachable_destinations_quarantine.h:272
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:266
std::vector< std::string > routing_instances_
Definition: unreachable_destinations_quarantine.h:279
void unregister_routing_callbacks()
Definition: unreachable_destinations_quarantine.cc:39
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:157
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:297
std::mutex unreachable_destinations_init_mutex_
Definition: unreachable_destinations_quarantine.h:277
std::mutex quarantine_empty_cond_m_
Definition: unreachable_destinations_quarantine.h:285
std::mutex routing_instances_mutex_
Definition: unreachable_destinations_quarantine.h:278
void register_routing_callbacks(QuarantineRoutingCallbacks &&routing_callbacks)
Definition: unreachable_destinations_quarantine.cc:33
std::chrono::milliseconds kQuarantinedConnectTimeout
Definition: unreachable_destinations_quarantine.h:268
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:56
Defines an IP address with port number
Definition: tcp_address.h:40
Definition: socket.h:1090
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:284
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:202
bool connect_timed_out_
Definition: unreachable_destinations_quarantine.h:251
std::vector< std::string > referencing_routing_instances_
Definition: unreachable_destinations_quarantine.h:240
bool connected_
Definition: unreachable_destinations_quarantine.h:252
net::io_context * io_ctx_
Definition: unreachable_destinations_quarantine.h:238
Function
Definition: unreachable_destinations_quarantine.h:254
net::ip::tcp::resolver::results_type endpoints_
Definition: unreachable_destinations_quarantine.h:246
stdx::expected< void, std::error_code > connected()
Definition: unreachable_destinations_quarantine.cc:498
net::steady_timer timer_
Definition: unreachable_destinations_quarantine.h:242
std::function< void()> on_delete_
Definition: unreachable_destinations_quarantine.h:264
Unreachable_destination_candidate & operator=(const Unreachable_destination_candidate &)=delete
std::error_code last_ec_
Definition: unreachable_destinations_quarantine.h:261
server_protocol_type::socket server_sock_
Definition: unreachable_destinations_quarantine.h:248
net::ip::tcp::resolver::results_type::iterator endpoints_it_
Definition: unreachable_destinations_quarantine.h:247
Unreachable_destination_candidate(const Unreachable_destination_candidate &)=delete
Function func_
Definition: unreachable_destinations_quarantine.h:259
stdx::expected< void, std::error_code > connect_finish()
Definition: unreachable_destinations_quarantine.cc:464
server_protocol_type::endpoint server_endpoint_
Definition: unreachable_destinations_quarantine.h:249
stdx::expected< void, std::error_code > resolve()
Definition: unreachable_destinations_quarantine.cc:386
stdx::expected< void, std::error_code > connect()
Definition: unreachable_destinations_quarantine.cc:363
stdx::expected< void, std::error_code > connect_init()
Definition: unreachable_destinations_quarantine.cc:408
stdx::expected< void, std::error_code > try_connect()
Definition: unreachable_destinations_quarantine.cc:419
Unreachable_destination_candidate & operator=(Unreachable_destination_candidate &&)=default
std::chrono::seconds quarantine_interval_
Definition: unreachable_destinations_quarantine.h:241
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:203
std::function< void()> on_connect_ok_
Definition: unreachable_destinations_quarantine.h:265
stdx::expected< void, std::error_code > init_endpoint()
Definition: unreachable_destinations_quarantine.cc:401
stdx::expected< void, std::error_code > next_endpoint()
Definition: unreachable_destinations_quarantine.cc:453
~Unreachable_destination_candidate()
Definition: unreachable_destinations_quarantine.cc:354
mysql_harness::TCPAddress address_
Definition: unreachable_destinations_quarantine.h:239
double seconds()
Definition: task.cc:310