mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-25477 Auto-create breaks replication when triggering event was not replicated
If UPDATE/DELETE does not change data it is skipped from replication. We now force replication of such events when they trigger partition auto-creation. For ROLLBACK it is as simple as set OPTION_KEEP_LOG flag. trans_cannot_safely_rollback() does the rest. For UPDATE/DELETE .. LIMIT 0 we make additional binlog_query() calls at the early points of return. As a safety measure we also convert row format into statement if it is needed. The condition is decided by binlog_need_stmt_format(). Basically if there are some row events in cache we don't need that: table open of row event will trigger auto-creation anyway. Multi-update/delete works via mysql_select(). There is no early points of return, so binlogging is always checked by send_eof()/abort_resultset(). But we must comply with the above measure of converting into statement.
This commit is contained in:
@@ -152,4 +152,148 @@ show create table t1;
|
||||
drop table t1;
|
||||
set timestamp= default;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-25477 Auto-create breaks replication when triggering event was not replicated
|
||||
--echo #
|
||||
|
||||
set timestamp= unix_timestamp('2001-01-01 01:00:00');
|
||||
--echo # ROLLBACK
|
||||
create table t (a int) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
insert into t values (1), (2);
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
|
||||
start transaction;
|
||||
delete from t;
|
||||
--disable_warnings
|
||||
rollback;
|
||||
# Warning: Some non-transactional changed tables couldn't be rolled back
|
||||
--enable_warnings
|
||||
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # INSERT .. ODKU
|
||||
--connection master
|
||||
create or replace table t (a int primary key) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
insert into t values (1), (2);
|
||||
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
insert into t values (1) on duplicate key update a= a;
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # INSERT .. SELECT .. ODKU
|
||||
--connection master
|
||||
create or replace table t (a int primary key) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
insert into t values (1), (2);
|
||||
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
--disable_warnings
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log");
|
||||
insert t select a from t where a = 1 limit 0 on duplicate key update a= 1;
|
||||
--enable_warnings
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # UPDATE
|
||||
--connection master
|
||||
create or replace table t (a int) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
insert into t values (1), (2);
|
||||
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
update t set a= 3 limit 0;
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # DELETE
|
||||
--connection master
|
||||
create or replace table t (a int) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
insert into t values (1), (2);
|
||||
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
delete from t limit 0;
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # Multi-update
|
||||
--connection master
|
||||
create or replace table t (a int) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
create or replace table t2 (b int);
|
||||
|
||||
insert into t values (0), (1);
|
||||
insert into t2 values (10), (20);
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
# Note: limit 0 is not important for multi-update/delete because they work
|
||||
# via mysql_select(). OTOH limit 0 makes unwanted "unsafe" warning.
|
||||
update t left join t2 on a > b set a= 4;
|
||||
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--echo # Multi-delete
|
||||
--connection master
|
||||
create or replace table t (a int) with system versioning
|
||||
partition by system_time interval 1 hour auto;
|
||||
create or replace table t2 (b int);
|
||||
|
||||
insert into t values (0), (1);
|
||||
insert into t2 values (10), (20);
|
||||
set @@timestamp= @@timestamp + 3601;
|
||||
delete t, t2 from t join t2 where a > b;
|
||||
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--sync_slave_with_master
|
||||
--replace_result InnoDB ENGINE MyISAM ENGINE MEMORY ENGINE
|
||||
show create table t;
|
||||
--connection master
|
||||
alter table t drop partition p0;
|
||||
--sync_slave_with_master
|
||||
|
||||
--connection master
|
||||
drop tables t, t2;
|
||||
set timestamp= default;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
Reference in New Issue
Block a user