Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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.
- Loading branch information
Showing
5 changed files
with
260 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| include/master-slave.inc | ||
| [connection master] | ||
| CREATE SEQUENCE s; | ||
| INSERT INTO s VALUES (1,1,4,1,1,1,0,0); | ||
| show create sequence s; | ||
| Table Create Table | ||
| s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 4 increment by 1 cache 1 nocycle ENGINE=MyISAM | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 1 | ||
| connection slave; | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 2 | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 3 | ||
| connection master; | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 2 | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 3 | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 4 | ||
| select * from s; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 5 1 4 1 1 1 0 0 | ||
| connection slave; | ||
| select * from s; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 5 1 4 1 1 1 0 0 | ||
| connection master; | ||
| DROP SEQUENCE s; | ||
| CREATE SEQUENCE s; | ||
| INSERT INTO s VALUES (1,1,3,1,1,1,1,0); | ||
| show create sequence s; | ||
| Table Create Table | ||
| s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 3 increment by 1 cache 1 cycle ENGINE=MyISAM | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 1 | ||
| connection slave; | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 2 | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 3 | ||
| connection master; | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 2 | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 3 | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 1 | ||
| select * from s; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 2 1 3 1 1 1 1 1 | ||
| connection slave; | ||
| select * from s; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 2 1 3 1 1 1 1 1 | ||
| connection master; | ||
| DROP SEQUENCE s; | ||
| CREATE SEQUENCE s; | ||
| INSERT INTO s VALUES (1,1,3,1,1,1,1,0); | ||
| SELECT NEXTVAL(s); | ||
| NEXTVAL(s) | ||
| 1 | ||
| 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 $ | ||
| connect con1,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con2,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con3,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con4,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con5,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con6,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con7,localhost,root,,; | ||
| CALL pr(100); | ||
| connect con8,localhost,root,,; | ||
| CALL pr(100); | ||
| connection master; | ||
| connection slave; | ||
| connection master; | ||
| DROP SEQUENCE s; | ||
| DROP PROCEDURE pr; | ||
| include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| --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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters