-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-38849 slave_connections_needed_for_purge prevents independent machine from purging binary logs #5559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 11.4
Are you sure you want to change the base?
MDEV-38849 slave_connections_needed_for_purge prevents independent machine from purging binary logs #5559
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| include/master-slave.inc | ||
| [connection master] | ||
| NOT FOUND /slave_connections_needed_for_purge/ in mysqld.1.err | ||
| connection slave; | ||
| START SLAVE IO_THREAD; | ||
| include/wait_for_slave_io_to_start.inc | ||
| FOUND 1 /slave_connections_needed_for_purge/ in mysqld.1.err | ||
| include/stop_slave_io.inc | ||
| START SLAVE IO_THREAD; | ||
| include/wait_for_slave_io_to_start.inc | ||
| include/stop_slave_io.inc | ||
| include/rpl_restart_server.inc [server_number=1 parameters: --slave-connections-needed-for-purge 0] | ||
| connection slave; | ||
| START SLAVE IO_THREAD; | ||
| include/wait_for_slave_io_to_start.inc | ||
| include/stop_slave_io.inc | ||
| include/rpl_restart_server.inc [server_number=1] | ||
| connection master; | ||
| SET @@GLOBAL.slave_connections_needed_for_purge= DEFAULT; | ||
| connection slave; | ||
| START SLAVE IO_THREAD; | ||
| include/wait_for_slave_io_to_start.inc | ||
| connection master; | ||
| FOUND 1 /slave_connections_needed_for_purge/ in mysqld.1.err | ||
| include/rpl_end.inc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # MDEV-38849: Test the warning that the _default_ for | ||
| # `@@slave_connections_needed_for_purge` does not match the replication setup. | ||
| # (Do _not_ warn if `@@slave_connections_needed_for_purge` is manually set.) | ||
|
|
||
| --source include/have_binlog_format_mixed.inc # no actual binlog content | ||
| --let $rpl_skip_start_slave= 1 | ||
| --source include/master-slave.inc | ||
|
|
||
|
|
||
| --let SEARCH_FILE= `SELECT @@log_error` | ||
| --let SEARCH_PATTERN= slave_connections_needed_for_purge | ||
| # Not connected: should not warn | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
|
|
||
| --connection slave | ||
| START SLAVE IO_THREAD; | ||
| --source include/wait_for_slave_io_to_start.inc | ||
| # Connected when left as default: should warn | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
|
|
||
| --source include/stop_slave_io.inc | ||
| START SLAVE IO_THREAD; | ||
| --source include/wait_for_slave_io_to_start.inc | ||
| # Reconnected: should not warn a second time | ||
|
|
||
| --source include/stop_slave_io.inc | ||
| --let $rpl_server_parameters= --slave-connections-needed-for-purge 0 | ||
| --let $rpl_server_number= 1 | ||
| --source include/rpl_restart_server.inc | ||
| --connection slave | ||
| START SLAVE IO_THREAD; | ||
| --source include/wait_for_slave_io_to_start.inc | ||
| # Explicitly set to 0 in server options: should not warn | ||
|
|
||
| --source include/stop_slave_io.inc | ||
| --let $rpl_server_parameters= | ||
| --source include/rpl_restart_server.inc | ||
| --connection master | ||
| SET @@GLOBAL.slave_connections_needed_for_purge= DEFAULT; | ||
| --connection slave | ||
| START SLAVE IO_THREAD; | ||
| --source include/wait_for_slave_io_to_start.inc | ||
| # Explicitly set to DEFAULT in system variables: should _not_ warn | ||
|
|
||
| --connection master | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
|
|
||
| --let $rpl_only_running_threads= 1 | ||
| --source include/rpl_end.inc |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation is tricky because we don’t want to warn multiple times when the only slave disconnects and reconnects. My preferred solution is using a However, “when changed” turned out to be impractical to implement, for Server Options and System Variables don’t actually share code; specifically, Options do not call Variables’ I also had the alternative of a call-once block, implemented with the initialization of a function-local static.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ struct Slave_info | |
| }; | ||
|
|
||
|
|
||
| std::atomic<bool> warn_slaves_not_needed_for_purge= {true}; | ||
| Atomic_counter<uint32_t> binlog_dump_thread_count; | ||
| ulong rpl_status=RPL_NULL; | ||
| mysql_mutex_t LOCK_rpl_status; | ||
|
|
@@ -120,6 +121,13 @@ int THD::register_slave(uchar *packet, size_t packet_length) | |
| Slave_info *si; | ||
| uchar *p= packet, *p_end= packet + packet_length; | ||
| const char *errmsg= "Wrong parameters to function register_slave"; | ||
| if (variables.log_warnings >= 1 && // Verbosity Level "Binlog/Replication" | ||
| warn_slaves_not_needed_for_purge.exchange(false, | ||
| // no need to sync with `@@slave_connections_needed_for_purge` itself | ||
| std::memory_order_relaxed)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| sql_print_warning( | ||
| "`@@slave_connections_needed_for_purge` defaults to 0, which means " | ||
| "this master does not retain older logs even if slaves need them."); | ||
|
|
||
| if (check_access(this, PRIV_COM_REGISTER_SLAVE, any_db.str, NULL,NULL,0,0)) | ||
| return 1; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Galera slaves not count towards “when registering a slave”?
If not, what’s the definitive way to distinguish Galera mode?