mariadb/mysql-test/suite/sql_sequence/slave_nextval.test
Michael Widenius 211f9eea60 MDEV-14092 NEXTVAL fails on slave
The problem was that the code in replication didn't distinguish between a
setval() failing because the stored sequence number was bigger than the
current (should have been ignored) and a failure from the storage engine.
2017-10-19 13:25:02 +03:00

132 lines
2.2 KiB
Text

--source include/master-slave.inc
--source include/have_binlog_format_row.inc
#
# MDEV-14092 NEXTVAL() fails on slave
#
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,4,1,1,1,0,0);
show create sequence s;
SELECT NEXTVAL(s);
--sync_slave_with_master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
--connection master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
select * from s;
--sync_slave_with_master
select * from s;
--connection master
DROP SEQUENCE s;
#
# Same as above, but with cycles
#
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
show create sequence s;
SELECT NEXTVAL(s);
--sync_slave_with_master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
--connection master
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
select * from s;
--sync_slave_with_master
select * from s;
--connection master
DROP SEQUENCE s;
# Here is a bit more complicated concurrent scenario that
# causes the same effect without any updates on the slave. You might
# need to replace 100 with a bigger value if it doesn't happen on your
# machine right away.
CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
SELECT NEXTVAL(s);
--delimiter $
CREATE PROCEDURE pr(n INT)
BEGIN
DECLARE i INT DEFAULT 0;
WHILE i < n
DO
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SELECT NEXTVAL(s);
SET i= i+1;
END WHILE;
END $
--delimiter ;
--connect (con1,localhost,root,,)
--send CALL pr(100)
--connect (con2,localhost,root,,)
--send CALL pr(100)
--connect (con3,localhost,root,,)
--send CALL pr(100)
--connect (con4,localhost,root,,)
--send CALL pr(100)
--connect (con5,localhost,root,,)
--send CALL pr(100)
--connect (con6,localhost,root,,)
--send CALL pr(100)
--connect (con7,localhost,root,,)
--send CALL pr(100)
--connect (con8,localhost,root,,)
--send CALL pr(100)
--disable_query_log
--disable_result_log
--connection con1
--reap
--connection con2
--reap
--connection con3
--reap
--connection con4
--reap
--connection con5
--reap
--connection con6
--reap
--connection con7
--reap
--connection con8
--reap
--enable_query_log
--enable_result_log
--connection master
--sync_slave_with_master
--connection master
DROP SEQUENCE s;
DROP PROCEDURE pr;
#
# Cleanup
#
--source include/rpl_end.inc