@@ -134,7 +134,7 @@ def wait_until_mysql_connection(self) -> None:
134
134
# Increment this major API version when introducing breaking changes
135
135
LIBAPI = 0
136
136
137
- LIBPATCH = 67
137
+ LIBPATCH = 69
138
138
139
139
UNIT_TEARDOWN_LOCKNAME = "unit-teardown"
140
140
UNIT_ADD_LOCKNAME = "unit-add"
@@ -890,6 +890,7 @@ def render_mysqld_configuration( # noqa: C901
890
890
audit_log_strategy : str ,
891
891
memory_limit : Optional [int ] = None ,
892
892
experimental_max_connections : Optional [int ] = None ,
893
+ binlog_retention_days : int ,
893
894
snap_common : str = "" ,
894
895
) -> tuple [str , dict ]:
895
896
"""Render mysqld ini configuration file."""
@@ -939,6 +940,7 @@ def render_mysqld_configuration( # noqa: C901
939
940
# disable memory instruments if we have less than 2GiB of RAM
940
941
performance_schema_instrument = "'memory/%=OFF'"
941
942
943
+ binlog_retention_seconds = binlog_retention_days * 24 * 60 * 60
942
944
config = configparser .ConfigParser (interpolation = None )
943
945
944
946
# do not enable slow query logs, but specify a log file path in case
@@ -954,6 +956,7 @@ def render_mysqld_configuration( # noqa: C901
954
956
"general_log" : "ON" ,
955
957
"general_log_file" : f"{ snap_common } /var/log/mysql/general.log" ,
956
958
"slow_query_log_file" : f"{ snap_common } /var/log/mysql/slowquery.log" ,
959
+ "binlog_expire_logs_seconds" : f"{ binlog_retention_seconds } " ,
957
960
"loose-audit_log_policy" : "LOGINS" ,
958
961
"loose-audit_log_file" : f"{ snap_common } /var/log/mysql/audit.log" ,
959
962
}
@@ -1044,7 +1047,6 @@ def install_plugins(self, plugins: list[str]) -> None:
1044
1047
try :
1045
1048
installed_plugins = self ._get_installed_plugins ()
1046
1049
# disable super_read_only to install plugins
1047
- self .set_dynamic_variable ("super_read_only" , "OFF" )
1048
1050
for plugin in plugins :
1049
1051
if plugin in installed_plugins :
1050
1052
# skip if the plugin is already installed
@@ -1054,9 +1056,15 @@ def install_plugins(self, plugins: list[str]) -> None:
1054
1056
logger .warning (f"{ plugin = } is not supported" )
1055
1057
continue
1056
1058
1059
+ command = supported_plugins [plugin ]
1060
+ if super_read_only :
1061
+ command = (
1062
+ f"SET GLOBAL super_read_only=OFF; { command } "
1063
+ "SET GLOBAL super_read_only=ON;"
1064
+ )
1057
1065
logger .info (f"Installing { plugin = } " )
1058
1066
self ._run_mysqlcli_script (
1059
- supported_plugins [ plugin ] ,
1067
+ command ,
1060
1068
user = self .server_config_user ,
1061
1069
password = self .server_config_password ,
1062
1070
)
@@ -1065,25 +1073,27 @@ def install_plugins(self, plugins: list[str]) -> None:
1065
1073
f"Failed to install { plugin = } " , # type: ignore
1066
1074
)
1067
1075
raise MySQLPluginInstallError
1068
- finally :
1069
- # restore original super_read_only value
1070
- if super_read_only :
1071
- self .set_dynamic_variable ("super_read_only" , "ON" )
1072
1076
1073
1077
def uninstall_plugins (self , plugins : list [str ]) -> None :
1074
1078
"""Uninstall plugins."""
1075
1079
super_read_only = self .get_variable_value ("super_read_only" ).lower () == "on"
1076
1080
try :
1077
1081
installed_plugins = self ._get_installed_plugins ()
1078
1082
# disable super_read_only to uninstall plugins
1079
- self .set_dynamic_variable ("super_read_only" , "OFF" )
1080
1083
for plugin in plugins :
1081
1084
if plugin not in installed_plugins :
1082
1085
# skip if the plugin is not installed
1083
1086
continue
1084
1087
logger .debug (f"Uninstalling plugin { plugin } " )
1088
+
1089
+ command = f"UNINSTALL PLUGIN { plugin } ;"
1090
+ if super_read_only :
1091
+ command = (
1092
+ f"SET GLOBAL super_read_only=OFF; { command } "
1093
+ "SET GLOBAL super_read_only=ON;"
1094
+ )
1085
1095
self ._run_mysqlcli_script (
1086
- f"UNINSTALL PLUGIN { plugin } " ,
1096
+ command ,
1087
1097
user = self .server_config_user ,
1088
1098
password = self .server_config_password ,
1089
1099
)
@@ -1092,10 +1102,6 @@ def uninstall_plugins(self, plugins: list[str]) -> None:
1092
1102
f"Failed to uninstall { plugin = } " , # type: ignore
1093
1103
)
1094
1104
raise MySQLPluginInstallError
1095
- finally :
1096
- # restore original super_read_only value
1097
- if super_read_only :
1098
- self .set_dynamic_variable ("super_read_only" , "ON" )
1099
1105
1100
1106
def _get_installed_plugins (self ) -> set [str ]:
1101
1107
"""Return a set of explicitly installed plugins."""
0 commit comments