diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-06-14 18:38:31 -0600 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-06-14 18:38:31 -0600 |
commit | dd0e62b34d2e409e2c8430c718dc005a58d6792e (patch) | |
tree | b922732ecd08dd61a88034a42499f42d6d2c15fc | |
parent | 75a65d3201a4486af96cf3277b6c5a4ba460eef7 (diff) | |
download | mariadb-git-10.3-MDEV-20219.tar.gz |
MDEV-20219: PURGE BINARY LOGS does not always purge10.3-MDEV-20219
THIS COMMIT IS FOR DEMONSTRATION ONLY
PURGE BINARY LOGS (as intended) does not purge logs
that are open. When one thread is reading the logs, for
example via SHOW BINLOG EVENTS, then an issued
PURGE command will not delete the log while it is open
by SHOW. This commit provides a test/result to demonstrate
this behavior. With respect to MDEV-20219, the code inside
of the backup utility has a comment before purging stating
//be carefull with this step if you have slaves!
which leads me to believe this issue is due to the above
behavior.
-rw-r--r-- | mysql-test/suite/binlog/r/purge_not_deleting_on_concurrent_reads.result | 23 | ||||
-rw-r--r-- | mysql-test/suite/binlog/t/purge_not_deleting_on_concurrent_reads.test | 30 | ||||
-rw-r--r-- | sql/sql_repl.cc | 2 |
3 files changed, 55 insertions, 0 deletions
diff --git a/mysql-test/suite/binlog/r/purge_not_deleting_on_concurrent_reads.result b/mysql-test/suite/binlog/r/purge_not_deleting_on_concurrent_reads.result new file mode 100644 index 00000000000..84890dd2285 --- /dev/null +++ b/mysql-test/suite/binlog/r/purge_not_deleting_on_concurrent_reads.result @@ -0,0 +1,23 @@ +connect con1,localhost,root,,; +FLUSH LOGS; +FLUSH LOGS; +FLUSH LOGS; +PURGE BINARY LOGS to 'master-bin.000004'; +FLUSH LOGS; +connect con2,localhost,root,,; +SET DEBUG_SYNC= "show_binlog_events_got_linfo WAIT_FOR purge_finished"; +SHOW BINLOG EVENTS; +connection con1; +PURGE BINARY LOGS to 'master-bin.000005'; +SET DEBUG_SYNC= "now SIGNAL purge_finished"; +connection con2; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000004 4 Format_desc 1 256 Server ver: 10.3.30-MariaDB-debug-log, Binlog ver: 4 +master-bin.000004 256 Gtid_list 1 285 [] +master-bin.000004 285 Binlog_checkpoint 1 329 master-bin.000003 +master-bin.000004 329 Binlog_checkpoint 1 373 master-bin.000004 +master-bin.000004 373 Rotate 1 421 master-bin.000005;pos=4 +# -- Index File: +./master-bin.000004 +./master-bin.000005 +SET debug_sync = 'reset'; diff --git a/mysql-test/suite/binlog/t/purge_not_deleting_on_concurrent_reads.test b/mysql-test/suite/binlog/t/purge_not_deleting_on_concurrent_reads.test new file mode 100644 index 00000000000..c5c8b869569 --- /dev/null +++ b/mysql-test/suite/binlog/t/purge_not_deleting_on_concurrent_reads.test @@ -0,0 +1,30 @@ +--source include/have_debug.inc +--source include/have_debug_sync.inc + +--source include/have_binlog_format_row.inc + +connect(con1,localhost,root,,); +FLUSH LOGS; +FLUSH LOGS; +FLUSH LOGS; +PURGE BINARY LOGS to 'master-bin.000004'; +FLUSH LOGS; + +connect(con2,localhost,root,,); +SET DEBUG_SYNC= "show_binlog_events_got_linfo WAIT_FOR purge_finished"; +--send SHOW BINLOG EVENTS + +--connection con1 +PURGE BINARY LOGS to 'master-bin.000005'; +SET DEBUG_SYNC= "now SIGNAL purge_finished"; + +--connection con2 +--reap + +--let $datadir= `SELECT @@datadir` +--let $index=$datadir/mysqld-bin.index +--echo # -- Index File: +--cat_file $index + + +SET debug_sync = 'reset';
\ No newline at end of file diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 389346e389d..6c16e5b6c46 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -4015,6 +4015,8 @@ bool mysql_show_binlog_events(THD* thd) thd->current_linfo= &linfo; + DEBUG_SYNC(thd, "show_binlog_events_got_linfo"); + if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0) goto err; |