@@ -127,7 +127,7 @@ def wait_until_mysql_connection(self) -> None:
127
127
# Increment this major API version when introducing breaking changes
128
128
LIBAPI = 0
129
129
130
- LIBPATCH = 91
130
+ LIBPATCH = 92
131
131
132
132
UNIT_TEARDOWN_LOCKNAME = "unit-teardown"
133
133
UNIT_ADD_LOCKNAME = "unit-add"
@@ -2025,26 +2025,47 @@ def add_instance_to_cluster(
2025
2025
# always release the lock
2026
2026
self ._release_lock (local_lock_instance , instance_unit_label , UNIT_ADD_LOCKNAME )
2027
2027
2028
- def rejoin_instance_to_cluster (self , * , unit_label : str , from_instance : str ) -> None :
2029
- """Rejoin an instance to the InnoDB cluster."""
2028
+ def rejoin_instance_to_cluster (
2029
+ self , * , unit_address : str , unit_label : str , from_instance : str
2030
+ ) -> None :
2031
+ """Rejoin an instance to the InnoDB cluster.
2032
+
2033
+ Args:
2034
+ unit_address: The address of the unit to rejoin.
2035
+ unit_label: The label of the unit to rejoin.
2036
+ from_instance: The instance from which to rejoin the cluster.
2037
+ """
2038
+ options = {"password" : self .server_config_password }
2030
2039
commands = (
2031
2040
f"cluster = dba.get_cluster('{ self .cluster_name } ')" ,
2032
- f"cluster.rejoin_instance('{ unit_label } ')" ,
2041
+ f"cluster.rejoin_instance('{ self .instance_def (self .server_config_user , unit_address )} ',"
2042
+ f"{ options } )" ,
2033
2043
)
2034
2044
2035
2045
from_instance = from_instance or self .instance_address
2046
+ if not self ._acquire_lock (
2047
+ from_instance ,
2048
+ unit_label ,
2049
+ UNIT_ADD_LOCKNAME ,
2050
+ ):
2051
+ raise MySQLLockAcquisitionError ("Lock not acquired" )
2036
2052
2037
2053
try :
2038
- logger .debug (f"Rejoining instance { unit_label } to cluster { self .cluster_name } " )
2054
+ logger .debug (f"Rejoining instance { unit_address } to cluster { self .cluster_name } " )
2039
2055
self ._run_mysqlsh_script (
2040
2056
"\n " .join (commands ),
2041
2057
user = self .server_config_user ,
2042
2058
password = self .server_config_password ,
2043
2059
host = self .instance_def (self .server_config_user , from_instance ),
2044
2060
)
2045
2061
except MySQLClientError as e :
2046
- logger .error (f"Failed to rejoin instance { unit_label } to cluster { self .cluster_name } " )
2062
+ logger .error (
2063
+ f"Failed to rejoin instance { unit_address } to cluster { self .cluster_name } "
2064
+ )
2047
2065
raise MySQLRejoinInstanceToClusterError from e
2066
+ finally :
2067
+ # always release the lock
2068
+ self ._release_lock (from_instance , unit_label , UNIT_ADD_LOCKNAME )
2048
2069
2049
2070
def is_instance_configured_for_innodb (
2050
2071
self , instance_address : str , instance_unit_label : str
@@ -2892,17 +2913,19 @@ def force_quorum_from_instance(self) -> None:
2892
2913
2893
2914
Recovery for cases where majority loss put the cluster in defunct state.
2894
2915
"""
2916
+ instance_definition = self .instance_def (self .server_config_user )
2895
2917
force_quorum_command = (
2896
2918
f"cluster = dba.get_cluster('{ self .cluster_name } ')" ,
2897
- "cluster.force_quorum_using_partition_of()" ,
2919
+ f"cluster.force_quorum_using_partition_of('{ self .server_config_user } @"
2920
+ f"{ instance_definition } ','{ self .server_config_password } ')" ,
2898
2921
)
2899
2922
2900
2923
try :
2901
2924
self ._run_mysqlsh_script (
2902
2925
"\n " .join (force_quorum_command ),
2903
2926
user = self .server_config_user ,
2904
2927
password = self .server_config_password ,
2905
- host = self . instance_def ( self . server_config_user ) ,
2928
+ host = instance_definition ,
2906
2929
)
2907
2930
except MySQLClientError as e :
2908
2931
logger .error ("Failed to force quorum from instance" )
0 commit comments