mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge remote-tracking branch 'github/bb-11.4-release' into bb-11.8-serg
This commit is contained in:
116
mysql-test/suite/binlog/r/binlog_commit_fail.result
Normal file
116
mysql-test/suite/binlog/r/binlog_commit_fail.result
Normal file
@@ -0,0 +1,116 @@
|
||||
set @@session.gtid_domain_id=1;
|
||||
set @save_gtid_stric_mode=@@global.gtid_strict_mode;
|
||||
create table ta (a int) engine=aria;
|
||||
create table ti (a int) engine=innodb;
|
||||
create table ti_pk (a int primary key) engine=innodb;
|
||||
create table t (a int) engine=innodb;
|
||||
create function f_i()
|
||||
returns integer
|
||||
begin
|
||||
insert into ti set a=1;
|
||||
return 1;
|
||||
end |
|
||||
create function f_ia(arg int)
|
||||
returns integer
|
||||
begin
|
||||
insert into ti_pk set a=1;
|
||||
insert into ta set a=1;
|
||||
insert into ti_pk set a=arg;
|
||||
return 1;
|
||||
end |
|
||||
call mtr.add_suppression("Error writing file");
|
||||
select count(*) as zero from t;
|
||||
zero
|
||||
0
|
||||
select count(*) as zero from ta;
|
||||
zero
|
||||
0
|
||||
select count(*) as zero from ti;
|
||||
zero
|
||||
0
|
||||
# 1. simple Innodb test
|
||||
set @@global.gtid_strict_mode=0;
|
||||
set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
insert into t set a=1;
|
||||
ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled
|
||||
# observe effective rollback
|
||||
select count(*) as zero from t;
|
||||
zero
|
||||
0
|
||||
# 2. simple Aira test
|
||||
set @@global.gtid_strict_mode=0;
|
||||
set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
insert into ta values (1),(2);
|
||||
ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled
|
||||
# note no rollback
|
||||
select count(*) as '*NON-zero*' from ta;
|
||||
*NON-zero*
|
||||
2
|
||||
delete from ta;
|
||||
# 3. multi-engine test
|
||||
set @@global.gtid_strict_mode=0;
|
||||
set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
insert into ta set a=f_i();
|
||||
ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled
|
||||
# note no rollback..
|
||||
select count(*) as one from ta;
|
||||
one
|
||||
1
|
||||
# ..except transactional engine
|
||||
select count(*) as zero from ti;
|
||||
zero
|
||||
0
|
||||
delete from ta;
|
||||
set @@global.gtid_strict_mode=0;
|
||||
set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
insert into t set a=f_ia(0);
|
||||
ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled
|
||||
# note no rollback..
|
||||
select count(*) as one from ta;
|
||||
one
|
||||
1
|
||||
# ..except transactional engine
|
||||
select count(*) as zero from t;
|
||||
zero
|
||||
0
|
||||
select count(*) as zero from ti_pk;
|
||||
zero
|
||||
0
|
||||
delete from ta;
|
||||
# 4. create-table-select-f()
|
||||
set @@global.gtid_strict_mode=0;
|
||||
set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
create table f_x (a int) select f_i() as a;
|
||||
ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled
|
||||
# rollback indeed takes place in the pure transactional case
|
||||
select count(*) as zero from ti;
|
||||
zero
|
||||
0
|
||||
set @@global.gtid_strict_mode=0;
|
||||
set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
create table t_x (a int) engine=aria select f_ia(0) as a;
|
||||
ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled
|
||||
select * from t_x;
|
||||
ERROR 42S02: Table 'test.t_x' doesn't exist
|
||||
# **TODO**: fix MDEV-36027
|
||||
# **TODO**: the empty binlog is buggy ..
|
||||
include/show_binlog_events.inc
|
||||
# .. as non-transactional `ta` (and `t_x` sic!) are modified
|
||||
select count(*) as one from ta;
|
||||
one
|
||||
1
|
||||
select count(*) as zero from ti;
|
||||
zero
|
||||
0
|
||||
delete from ta;
|
||||
#.
|
||||
set @@global.gtid_strict_mode=@save_gtid_stric_mode;
|
||||
drop function f_i;
|
||||
drop function f_ia;
|
||||
drop table t, ta, ti, ti_pk;
|
@@ -18,6 +18,51 @@ drop table t1;
|
||||
# Ensuring file offset of binlog_f2_mid < binlog_f1_end
|
||||
#
|
||||
#
|
||||
# Test using --read-from-remote-server
|
||||
#
|
||||
connection default;
|
||||
#
|
||||
# --stop-position tests
|
||||
#
|
||||
# Case 1.a) With one binlog file, a --stop-position before the end of
|
||||
# the file should not result in a warning
|
||||
# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f1_pre_rotate binlog_f1_full --result-file=tmp/warn_position_test_file.out 2>&1
|
||||
#
|
||||
# Case 1.b) With one binlog file, a --stop-position at the exact end of
|
||||
# the file should not result in a warning
|
||||
# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f1_end binlog_f1_full --result-file=tmp/warn_position_test_file.out 2>&1
|
||||
#
|
||||
# Case 1.c) With one binlog file, a --stop-position past the end of the
|
||||
# file should(!) result in a warning
|
||||
# MYSQL_BINLOG --read-from-remote-server --short-form --stop-position=binlog_f1_over_eof binlog_f1_full --result-file=tmp/warn_position_test_file.out 2>&1
|
||||
WARNING: Did not reach stop position <BINLOG_F1_OVER_EOF> before end of input
|
||||
#
|
||||
# Case 2.a) With two binlog files, a --stop-position targeting b2 which
|
||||
# exists in the size of b1 should:
|
||||
# 1) not provide any warnings
|
||||
# 2) not prevent b2 from outputting its desired events before the
|
||||
# stop position
|
||||
# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f2_mid binlog_f1_full binlog_f2_full --result-file=tmp/warn_position_test_file.out 2>&1
|
||||
include/assert_grep.inc [Ensure all intended GTIDs are present]
|
||||
include/assert_grep.inc [Ensure the next GTID binlogged is _not_ present]
|
||||
#
|
||||
# Case 2.b) With two binlog files, a --stop-position targeting the end
|
||||
# of binlog 2 should:
|
||||
# 1) not provide any warnings
|
||||
# 2) not prevent b2 from outputting its entire binary log
|
||||
# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f2_end binlog_f1_full binlog_f2_full --result-file=tmp/warn_position_test_file.out 2>&1
|
||||
include/assert_grep.inc [Ensure a GTID exists for each transaction]
|
||||
include/assert_grep.inc [Ensure the last GTID binlogged is present]
|
||||
#
|
||||
# Case 2.c) With two binlog files, a --stop-position targeting beyond
|
||||
# the eof of binlog 2 should:
|
||||
# 1) provide a warning that the stop position was not reached
|
||||
# 2) not prevent b2 from outputting its entire binary log
|
||||
# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f2_over_eof binlog_f1_full binlog_f2_full --result-file=tmp/warn_position_test_file.out 2>&1
|
||||
WARNING: Did not reach stop position <BINLOG_F2_OVER_EOF> before end of input
|
||||
include/assert_grep.inc [Ensure a GTID exists for each transaction]
|
||||
#
|
||||
#
|
||||
# Test using local binlog files
|
||||
#
|
||||
connection default;
|
||||
|
135
mysql-test/suite/binlog/t/binlog_commit_fail.test
Normal file
135
mysql-test/suite/binlog/t/binlog_commit_fail.test
Normal file
@@ -0,0 +1,135 @@
|
||||
# Tests of commit time failures.
|
||||
# At committing of an auto-commit statement a failure to commit in its
|
||||
# binlog branch should rollback at least the transactional part of the statement.
|
||||
#
|
||||
# References:
|
||||
# MDEV-35506 commit policy of one-phase-commit even at errored-out binlogging leads to assert
|
||||
# MDEV-36027 Errored-out CREATE-SELECT does not binlog results of non-transactional table modification
|
||||
|
||||
source include/have_innodb.inc;
|
||||
source include/have_binlog_format_row.inc;
|
||||
|
||||
set @@session.gtid_domain_id=1;
|
||||
set @save_gtid_stric_mode=@@global.gtid_strict_mode;
|
||||
|
||||
create table ta (a int) engine=aria;
|
||||
create table ti (a int) engine=innodb;
|
||||
create table ti_pk (a int primary key) engine=innodb;
|
||||
create table t (a int) engine=innodb;
|
||||
delimiter |;
|
||||
create function f_i()
|
||||
returns integer
|
||||
begin
|
||||
insert into ti set a=1;
|
||||
return 1;
|
||||
end |
|
||||
create function f_ia(arg int)
|
||||
returns integer
|
||||
begin
|
||||
insert into ti_pk set a=1;
|
||||
insert into ta set a=1;
|
||||
insert into ti_pk set a=arg;
|
||||
return 1;
|
||||
end |
|
||||
delimiter ;|
|
||||
|
||||
call mtr.add_suppression("Error writing file");
|
||||
|
||||
# Naturally all empty now
|
||||
select count(*) as zero from t;
|
||||
select count(*) as zero from ta;
|
||||
select count(*) as zero from ti;
|
||||
|
||||
# Force manual value assignement to gtid::seq_no while in the strict mode
|
||||
# so that the value is rejected. Despite the errorred out statement
|
||||
# being at its commit phase it will eventually be rolled back.
|
||||
# Side effects of non-transactional engines, like Aria, are displayed.
|
||||
--echo # 1. simple Innodb test
|
||||
set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
# mask possible allowed seq_no shift
|
||||
--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
|
||||
--error ER_GTID_STRICT_OUT_OF_ORDER
|
||||
insert into t set a=1;
|
||||
|
||||
--echo # observe effective rollback
|
||||
select count(*) as zero from t;
|
||||
|
||||
--echo # 2. simple Aira test
|
||||
set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
|
||||
--error ER_GTID_STRICT_OUT_OF_ORDER
|
||||
insert into ta values (1),(2);
|
||||
|
||||
--echo # note no rollback
|
||||
select count(*) as '*NON-zero*' from ta;
|
||||
# local cleanup
|
||||
delete from ta;
|
||||
|
||||
--echo # 3. multi-engine test
|
||||
# A. non-transactional top-level
|
||||
set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
|
||||
--error ER_GTID_STRICT_OUT_OF_ORDER
|
||||
insert into ta set a=f_i();
|
||||
--echo # note no rollback..
|
||||
select count(*) as one from ta;
|
||||
--echo # ..except transactional engine
|
||||
select count(*) as zero from ti;
|
||||
delete from ta;
|
||||
|
||||
# B. non-transactional in the leaf
|
||||
set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
|
||||
--error ER_GTID_STRICT_OUT_OF_ORDER
|
||||
insert into t set a=f_ia(0);
|
||||
|
||||
--echo # note no rollback..
|
||||
select count(*) as one from ta;
|
||||
--echo # ..except transactional engine
|
||||
select count(*) as zero from t;
|
||||
select count(*) as zero from ti_pk;
|
||||
delete from ta;
|
||||
|
||||
--echo # 4. create-table-select-f()
|
||||
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
|
||||
--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
|
||||
# A. two phase commit branch
|
||||
set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
|
||||
--error ER_GTID_STRICT_OUT_OF_ORDER
|
||||
create table f_x (a int) select f_i() as a;
|
||||
--echo # rollback indeed takes place in the pure transactional case
|
||||
select count(*) as zero from ti;
|
||||
|
||||
# B. one phase commit branch
|
||||
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
|
||||
--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
|
||||
set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
|
||||
set @@global.gtid_strict_mode=1;
|
||||
--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
|
||||
--error ER_GTID_STRICT_OUT_OF_ORDER
|
||||
create table t_x (a int) engine=aria select f_ia(0) as a;
|
||||
--error ER_NO_SUCH_TABLE
|
||||
select * from t_x;
|
||||
|
||||
--echo # **TODO**: fix MDEV-36027
|
||||
--echo # **TODO**: the empty binlog is buggy ..
|
||||
--source include/show_binlog_events.inc
|
||||
--echo # .. as non-transactional `ta` (and `t_x` sic!) are modified
|
||||
select count(*) as one from ta;
|
||||
select count(*) as zero from ti;
|
||||
|
||||
delete from ta;
|
||||
--echo #.
|
||||
|
||||
# cleanup
|
||||
|
||||
set @@global.gtid_strict_mode=@save_gtid_stric_mode;
|
||||
drop function f_i;
|
||||
drop function f_ia;
|
||||
drop table t, ta, ti, ti_pk;
|
@@ -64,13 +64,12 @@ if ($binlog_f2_mid > $binlog_f1_end)
|
||||
--die Mid point chosen to end in binlog 2 does not exist in earlier binlog
|
||||
}
|
||||
|
||||
#--echo #
|
||||
#--echo #
|
||||
#--echo # Test using --read-from-remote-server
|
||||
#--echo #
|
||||
#--let $read_from_remote_server= 1
|
||||
#--emit warning is not supported by --read-from-remote-server now
|
||||
#--source binlog_mysqlbinlog_warn_stop_position.inc
|
||||
--echo #
|
||||
--echo #
|
||||
--echo # Test using --read-from-remote-server
|
||||
--echo #
|
||||
--let $read_from_remote_server= 1
|
||||
--source binlog_mysqlbinlog_warn_stop_position.inc
|
||||
|
||||
--echo #
|
||||
--echo #
|
||||
|
Reference in New Issue
Block a user