Hi, Monty, On Jul 09, Michael Widenius wrote:
revision-id: d78376da69d (mariadb-11.4.2-11-gd78376da69d) parent(s): 4ffeca643d5 author: Michael Widenius committer: Michael Widenius timestamp: 2024-07-09 11:01:29 +0300 message:
MDEV-34504 PURGE BINARY LOGS not working anymore
PURGE BINARY LOGS did not always purge binary logs. This commit fixes some of the issues and adds notifications if a binary log cannot be purged.
User visible changes: - 'PURGE BINARY LOG TO log_name' and 'PURGE BINARY LOGS BEFORE date' worked differently. 'TO' ignored 'slave_connections_needed_for_purge' while 'BEFORE' did not. Now both versions ignores the 'slave_connections_needed_for_purge variable'. - 'PURGE BINARY LOG..' commands now returns 'note' if a binary log cannot be deleted like Note 1375 Binary log 'master-bin.000004' is not purged because it is the current active binlog - Automatic binary log purges, based on date or size, will write a note to the error log if a binary log matching the size or date cannot yet be deleted. - If 'slave_connections_needed_for_purge' is set from a config or command line, it is set to 0 if Galera is enabled and 1 otherwise (old default). This ensures that automatic binary log purge works with Galera as before the addition of 'slave_connections_needed_for_purge'. If the variable is changed to 0, a warning will be printed to the error log.
Code changes: - Added THD argument to several purge_logs related functions that needed THD. - Added 'interactive' options to purge_logs functions. This allowed me to remove testing of sql_command == SQLCOM_PURGE.
it's not really _ineractive_ but ok
- Changed purge_logs_before_date() to first check if log is applicable before calling can_purge_logs(). This ensures we do not get a notification for logs that does not match the remove criteria. - MYSQL_BIN_LOG::can_purge_log() will write notifications to the user or error log if a log cannot yet be removed. - log_in_use() will return reason why a binary log cannot be removed. - Moved checking of binlog_format for Galera to be after Galera is initialized (The old check never worked). If Galera is enabled we now change the binlog_format to ROW, with a warning, instead of aborting the server. If this change happens, the binlog_format variable will be marked with AUTO or FORCED, for information_schema.system_variables, and a warning will be printed to the error log.
What's "FORCE"? "AUTO" means that the value was automatically changed by the server, "FORCE" means the same, it looks redundant. And it's not the "source of the value", better to revert that part.
- Print also a warning if FLASHBACK changes the binlog_format to ROW. Before this was done silently.
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2b12001de9e..604eaadcc92 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5847,7 +5850,28 @@ int mysqld_main(int argc, char **argv) #ifdef WITH_WSREP wsrep_set_wsrep_on(nullptr); if (WSREP_ON && wsrep_check_opts()) unireg_abort(1); -#endif + + if (!opt_bootstrap && WSREP_PROVIDER_EXISTS && WSREP_ON) + { + if (global_system_variables.binlog_format != BINLOG_FORMAT_ROW) + { + sql_print_warning("Binlog_format changed to \"ROW\" because of Galera");
should be sql_print_information()
+ global_system_variables.binlog_format= BINLOG_FORMAT_ROW; + mark_binlog_format_used(binlog_format_used); + } + binlog_format_used= 1; + if (!slave_connections_needed_for_purge_option_used) + { + slave_connections_needed_for_purge= + internal_slave_connections_needed_for_purge= 0; + mark_slave_connections_needed_for_purge_as_auto();
you don't need that, you can use SYSVAR_AUTOSIZE(internal_slave_connections_needed_for_purge, 0);
+ sql_print_information( + "slave_connections_needed_for_purge changed to 0 because " + "of Galera. Change it to 1 or higher if this Galera node " + "is also Master in a normal replication setup"); + } + } +#endif /* WITH_WSREP */
#ifdef _WIN32 /* @@ -8219,7 +8243,9 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument, ((enum_slave_parallel_mode)opt_slave_parallel_mode); break; } - + case (int) OPT_SLAVE_CONNECTIONS_NEEDED_FOR_PURGE: + slave_connections_needed_for_purge_option_used= 1;
you don't need that, you can use if (!IS_SYSVAR_AUTOSIZE(&internal_slave_connections_needed_for_purge))
+ break; case (int)OPT_BINLOG_IGNORE_DB: { binlog_filter->add_ignore_db(argument); @@ -8714,18 +8740,14 @@ static int get_options(int *argc_ptr, char ***argv_ptr) opt_bin_log= opt_bin_log_used= 1;
/* Force format to row */ + if (global_system_variables.binlog_format != BINLOG_FORMAT_ROW) + { + sql_print_warning("Binlog_format changed to \"ROW\" because of " + "flashback");
sql_print_information
+ global_system_variables.binlog_format= BINLOG_FORMAT_ROW; + mark_binlog_format_used(binlog_format_used); + } binlog_format_used= 1; - global_system_variables.binlog_format= BINLOG_FORMAT_ROW; - } - - if (!opt_bootstrap && WSREP_PROVIDER_EXISTS && WSREP_ON && - global_system_variables.binlog_format != BINLOG_FORMAT_ROW) - { - - WSREP_ERROR ("Only binlog_format = 'ROW' is currently supported. " - "Configured value: '%s'. Please adjust your configuration.", - binlog_format_names[global_system_variables.binlog_format]); - return 1; }
Regards, Sergei Chief Architect, MariaDB Server and security@mariadb.org