Skip to content
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

PS-9322 fix: With super_read_only=1, undo truncation cannot update DD and leaves orphan truncate log files (8.0) #5415

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions mysql-test/suite/innodb_undo/r/purge_on_replica.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
include/master-slave.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
[connection master]
# 1: Set replica parameters
set @orig_max_undo_log_size = @@innodb_max_undo_log_size;
set @orig_truncate_frequency = @@innodb_purge_rseg_truncate_frequency;
set global innodb_max_undo_log_size=10485760;
set global innodb_purge_rseg_truncate_frequency=1;
set global super_read_only=1;

# 2: Preparing database
create table t1(id int);
create procedure insert_data()
begin
declare i int;
set i=1;
while(i<=500000) do
insert into t1(id) values(i);
set i=i+1;
end while;
end;$$
begin;
# 3: Inserting data, filling undo logs
call insert_data();
# 4: commit, trigger undo log truncation
commit;
select tablespace_name, file_name from information_schema.files
where file_name like "%undo%";
TABLESPACE_NAME FILE_NAME
innodb_undo_001 ./undo_001
innodb_undo_002 ./undo_002
select name, row_format from information_schema.innodb_tablespaces
where name like '%undo%';
name row_format
innodb_undo_001 Undo
innodb_undo_002 Undo
# 5: undo files undo_001 and undo_002 are expected to exist,
# while files undo_001_trunc.log and undo_002_trunc.log are expected to not exist
undo_001
undo_002
set global innodb_max_undo_log_size=@orig_max_undo_log_size;
set global innodb_purge_rseg_truncate_frequency=@orig_truncate_frequency;
set global super_read_only = 0;
set global read_only = 0;
drop procedure insert_data;
drop table t1;
include/rpl_end.inc
71 changes: 71 additions & 0 deletions mysql-test/suite/innodb_undo/t/purge_on_replica.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
--source include/have_debug.inc
# The test requires a debug build, in order to trigger
# a purge using innodb_purge_run_now=ON .

--source include/master-slave.inc

--echo # 1: Set replica parameters
connection slave;

set @orig_max_undo_log_size = @@innodb_max_undo_log_size;
set @orig_truncate_frequency = @@innodb_purge_rseg_truncate_frequency;

# Trigger truncation of undo log files once they occupy more than 10MB
# which is the minimum value of innodb_max_undo_log_size
set global innodb_max_undo_log_size=10485760;
set global innodb_purge_rseg_truncate_frequency=1;
set global super_read_only=1;

--echo
--echo # 2: Preparing database
connection master;

create table t1(id int);

delimiter $$;
create procedure insert_data()
begin
declare i int;
set i=1;
while(i<=500000) do
insert into t1(id) values(i);
set i=i+1;
end while;
end;$$
delimiter ;$$

begin;

--echo # 3: Inserting data, filling undo logs
call insert_data();

--echo # 4: commit, trigger undo log truncation
commit;
sync_slave_with_master;

connection slave;

--source include/wait_innodb_all_purged.inc


# expecting two undo files, and no undo_*_trunc.log files remaining

select tablespace_name, file_name from information_schema.files
where file_name like "%undo%";
select name, row_format from information_schema.innodb_tablespaces
where name like '%undo%';

let $MYSQLD_DATADIR = `select @@datadir`;

--echo # 5: undo files undo_001 and undo_002 are expected to exist,
--echo # while files undo_001_trunc.log and undo_002_trunc.log are expected to not exist
list_files $MYSQLD_DATADIR undo_0*;

set global innodb_max_undo_log_size=@orig_max_undo_log_size;
set global innodb_purge_rseg_truncate_frequency=@orig_truncate_frequency;
set global super_read_only = 0;
set global read_only = 0;
connection master;
drop procedure insert_data;
drop table t1;
--source include/rpl_end.inc
4 changes: 4 additions & 0 deletions storage/innobase/srv/srv0srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "row0log.h"
#include "row0mysql.h"
#include "sql/current_thd.h"
#include "sql/sql_class.h"
#include "sql_thd_internal_api.h"
#include "srv0mon.h"

Expand Down Expand Up @@ -3438,6 +3439,9 @@ void srv_purge_coordinator_thread() {

THD *thd = create_internal_thd();

// Allow purge in read only mode as well.
thd->set_skip_readonly_check();

purge_sys->is_this_a_purge_thread = true;

ulint n_total_purged = ULINT_UNDEFINED;
Expand Down
Loading