14.18.3 Asynchronous Replication Channel Failover Functions (original) (raw)

14.18.3 Asynchronous Replication Channel Failover Functions

The following functions, which are available from MySQL 8.0.22 for standard source to replica replication and from MySQL 8.0.23 for Group Replication, enable you to add and remove replication source servers from the source list for a replication channel. From MySQL 8.0.27, you can also clear the source list for a server.

The asynchronous connection failover mechanism automatically establishes an asynchronous (source to replica) replication connection to a new source from the appropriate list after the existing connection from the replica to its source fails. From MySQL 8.0.23, the connection is also changed if the currently connected source does not have the highest weighted priority in the group. For Group Replication source servers that are defined as part of a managed group, the connection is also failed over to another group member if the currently connected source leaves the group or is no longer in the majority. For more information on the mechanism, seeSection 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”.

Source lists are stored in themysql.replication_asynchronous_connection_failover andmysql.replication_asynchronous_connection_failover_managed tables, and can be viewed in the Performance Schemareplication_asynchronous_connection_failover table.

If the replication channel is on a Group Replication primary for a group where failover between replicas is active, the source list is broadcast to all the group members when they join or when it is updated by any method. Failover between replicas is controlled by themysql_start_failover_channels_if_primary member action, which is enabled by default, and can be disabled using thegroup_replication_disable_member_action function.

asynchronous_connection_failover_add_managed(channel, managed_type, managed_name, host, port, network_namespace, primary_weight, secondary_weight)  

Arguments:

SELECT asynchronous_connection_failover_add_managed('channel2', 'GroupReplication', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '127.0.0.1', 3310, '', 80, 60);  
+----------------------------------------------------------------------------------------------------------------------------------------------------+  
| asynchronous_connection_failover_add_source('channel2', 'GroupReplication', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '127.0.0.1', 3310, '', 80, 60) |  
+----------------------------------------------------------------------------------------------------------------------------------------------------+  
| Source managed configuration details successfully inserted.                                                                                        |  
+----------------------------------------------------------------------------------------------------------------------------------------------------+  

For more information, seeSection 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”.

asynchronous_connection_failover_add_source(channel, host, port, network_namespace, weight)  

Arguments:

SELECT asynchronous_connection_failover_add_source('channel2', '127.0.0.1', 3310, '', 80);  
+-------------------------------------------------------------------------------------------------+  
| asynchronous_connection_failover_add_source('channel2', '127.0.0.1', 3310, '', 80)              |  
+-------------------------------------------------------------------------------------------------+  
| Source configuration details successfully inserted.                                             |  
+-------------------------------------------------------------------------------------------------+  

For more information, seeSection 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”.

asynchronous_connection_failover_delete_managed(channel, managed_name)  

Arguments:

SELECT asynchronous_connection_failover_delete_managed('channel2', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa');  
+-----------------------------------------------------------------------------------------------------+  
| asynchronous_connection_failover_delete_managed('channel2', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') |  
+-----------------------------------------------------------------------------------------------------+  
| Source managed configuration details successfully deleted.                                          |  
+-----------------------------------------------------------------------------------------------------+  

For more information, seeSection 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”.

asynchronous_connection_failover_delete_source(channel, host, port, network_namespace)  

Arguments:

SELECT asynchronous_connection_failover_delete_source('channel2', '127.0.0.1', 3310, '');  
+------------------------------------------------------------------------------------------------+  
| asynchronous_connection_failover_delete_source('channel2', '127.0.0.1', 3310, '')              |  
+------------------------------------------------------------------------------------------------+  
| Source configuration details successfully deleted.                                             |  
+------------------------------------------------------------------------------------------------+  

For more information, seeSection 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”.

STRING asynchronous_connection_failover_reset()  

Arguments:
None.
Return value:
A string containing the result of the operation, for example whether it was successful or not.
Example:

mysql> SELECT asynchronous_connection_failover_reset();  
+-------------------------------------------------------------------------+  
| asynchronous_connection_failover_reset()                                |  
+-------------------------------------------------------------------------+  
| The UDF asynchronous_connection_failover_reset() executed successfully. |  
+-------------------------------------------------------------------------+  
1 row in set (0.00 sec)  

For more information, seeSection 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”.