mirror of
https://github.com/MariaDB/server.git
synced 2025-12-09 08:01:34 +03:00
BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFE
Problem: Statements that write to tables with auto_increment columns
based on the selection from another table, may lead to master
and slave going out of sync, as the order in which the rows
are retrived from the table may differ on master and slave.
Solution: We mark writing to a table with auto_increment table
as unsafe. This will cause the execution of such statements to
throw a warning and forces the statement to be logged in ROW if
the logging format is mixed.
Changes:
1. All the statements that writes to a table with auto_increment
column(s) based on the rows fetched from another table, will now
be unsafe.
2. CREATE TABLE with SELECT will now be unsafe.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
|
||||
drop database if exists test1;
|
||||
create database test1;
|
||||
use test1;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
|
||||
create table t1(a int auto_increment, primary key(a));
|
||||
create table t2(b int auto_increment, c int, primary key(b));
|
||||
insert into t1 values (1),(2),(3);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
|
||||
CREATE TABLE t1 (
|
||||
a int unsigned not null auto_increment primary key,
|
||||
b int unsigned
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
|
||||
drop table if exists t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
a int unsigned not null auto_increment primary key,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
|
||||
|
||||
-------- Test for BUG#9361 --------
|
||||
CREATE TABLE t1 (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
|
||||
start slave;
|
||||
Got one of the listed errors
|
||||
start slave;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
# Test supplied by Are Casilla
|
||||
|
||||
source include/master-slave.inc;
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
|
||||
--disable_warnings
|
||||
connection master;
|
||||
drop database if exists test1;
|
||||
@@ -42,12 +43,16 @@ CREATE PROCEDURE simpleproc3 ()
|
||||
$
|
||||
DELIMITER ;$
|
||||
|
||||
--disable_warnings
|
||||
CALL simpleproc3();
|
||||
--enable_warnings
|
||||
|
||||
select * from t2;
|
||||
|
||||
TRUNCATE TABLE `t1`;
|
||||
--disable_warnings
|
||||
CALL simpleproc3();
|
||||
--enable_warnings
|
||||
|
||||
select * from t1;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#######################################################
|
||||
--source include/not_ndb_default.inc
|
||||
--source include/master-slave.inc
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
|
||||
let $engine_type=MyISAM;
|
||||
--source extra/rpl_tests/rpl_multi_update2.test
|
||||
--source include/rpl_end.inc
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#######################################################
|
||||
--source include/not_ndb_default.inc
|
||||
--source include/master-slave.inc
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
|
||||
let $engine_type=MyISAM;
|
||||
-- source extra/rpl_tests/rpl_multi_update3.test
|
||||
--source include/rpl_end.inc
|
||||
|
||||
@@ -19,6 +19,7 @@ enable_query_log;
|
||||
|
||||
create table t1 (a int not null auto_increment primary key, b int, key(b));
|
||||
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||
--disable_warnings
|
||||
INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
@@ -32,6 +33,7 @@ INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
INSERT INTO t1 (a) SELECT null FROM t1;
|
||||
--enable_warnings
|
||||
save_master_pos;
|
||||
# a few updates to force OPTIMIZE to do something
|
||||
--disable_warnings
|
||||
|
||||
@@ -27,6 +27,7 @@ EOF
|
||||
chmod 0000 $MYSQLD_SLAVE_DATADIR/master.info;
|
||||
connection slave;
|
||||
|
||||
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
|
||||
# START SLAVE will fail because it can't read the file (mode 000)
|
||||
# (system error 13)
|
||||
--replace_result $MYSQL_TEST_DIR TESTDIR
|
||||
|
||||
@@ -52,9 +52,10 @@ SET GLOBAL event_scheduler = ON;
|
||||
replace_result $engine_type ENGINE_TYPE;
|
||||
eval CREATE TABLE t1 (i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f varchar(8)) ENGINE=$engine_type;
|
||||
INSERT INTO t1 (f) VALUES ('a'),('a'),('a'),('a'),('a');
|
||||
--disable_warnings
|
||||
INSERT INTO t1 SELECT i+5, f FROM t1;
|
||||
INSERT INTO t1 SELECT i+10, f FROM t1;
|
||||
|
||||
--enable_warnings
|
||||
CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND
|
||||
DO INSERT INTO t1 VALUES (SLEEP(5),CONCAT('ev1_',CONNECTION_ID()));
|
||||
CREATE EVENT ev2 ON SCHEDULE EVERY 1 SECOND
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
# timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem
|
||||
# and possibly Konstantin).
|
||||
|
||||
source include/master-slave.inc;
|
||||
|
||||
--disable_query_log
|
||||
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
--enable_query_log
|
||||
|
||||
--disable_ps_protocol
|
||||
|
||||
source include/master-slave.inc;
|
||||
|
||||
# Save original timezone
|
||||
set @my_time_zone= @@global.time_zone;
|
||||
|
||||
@@ -90,6 +90,7 @@ insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
|
||||
# from originally inserted)
|
||||
#
|
||||
set time_zone='MET';
|
||||
--disable_warnings ONCE
|
||||
insert into t2 (select * from t1);
|
||||
SELECT * FROM t1 ORDER BY n;
|
||||
sync_slave_with_master;
|
||||
|
||||
Reference in New Issue
Block a user