Skip to content

Commit

Permalink
MDEV-19959 : Galera test failure on galera_binlog_stmt_autoinc
Browse files Browse the repository at this point in the history
Make sure that nodes have correct auto_increment_offset when
they start and when control is turned on.
  • Loading branch information
Jan Lindström committed May 9, 2022
1 parent 79660e5 commit 66d93a8
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 61 deletions.
88 changes: 61 additions & 27 deletions mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
connection node_1;
SET GLOBAL auto_increment_offset=1;
connection node_2;
SET GLOBAL auto_increment_offset=2;
connection node_1;
connection node_2;
connection node_2;
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
connection node_1;
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 1
insert into t1(i) values(null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
3 dummy_text
5 dummy_text
7 dummy_text
connection node_2;
select * from t1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 2
select * from t1 order by i;
i c
1 dummy_text
3 dummy_text
Expand All @@ -39,23 +50,30 @@ SET GLOBAL wsrep_auto_increment_control='OFF';
SET SESSION auto_increment_increment = 3;
SET SESSION auto_increment_offset = 1;
CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 3
auto_increment_offset 1
insert into t1(i) values(null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
4 dummy_text
7 dummy_text
10 dummy_text
connection node_2;
select * from t1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 2
select * from t1 order by i;
i c
1 dummy_text
4 dummy_text
Expand All @@ -64,6 +82,7 @@ i c
connection node_1;
SET GLOBAL wsrep_auto_increment_control='ON';
SET SESSION binlog_format='ROW';
connection node_1;
show variables like 'binlog_format';
Variable_name Value
binlog_format ROW
Expand All @@ -79,29 +98,37 @@ auto_increment_increment 3
auto_increment_offset 1
wsrep_auto_increment_control OFF
SET GLOBAL wsrep_auto_increment_control='ON';
connection node_1;
drop table t1;
connection node_2;
SET GLOBAL wsrep_forced_binlog_format='ROW';
connection node_1;
SET GLOBAL wsrep_forced_binlog_format='ROW';
CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 1
insert into t1(i) values(null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
3 dummy_text
5 dummy_text
7 dummy_text
connection node_2;
select * from t1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 2
select * from t1 order by i;
i c
1 dummy_text
3 dummy_text
Expand All @@ -119,23 +146,30 @@ SET GLOBAL wsrep_auto_increment_control='OFF';
SET SESSION auto_increment_increment = 3;
SET SESSION auto_increment_offset = 1;
CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 3
auto_increment_offset 1
insert into t1(i) values(null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
select * from t1 order by i;
i c
1 dummy_text
4 dummy_text
7 dummy_text
10 dummy_text
connection node_2;
select * from t1;
show variables like 'auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 2
select * from t1 order by i;
i c
1 dummy_text
4 dummy_text
Expand All @@ -149,13 +183,13 @@ binlog_format ROW
show variables like '%auto_increment%';
Variable_name Value
auto_increment_increment 2
auto_increment_offset 1
auto_increment_offset 2
wsrep_auto_increment_control ON
SET GLOBAL wsrep_auto_increment_control='OFF';
show variables like '%auto_increment%';
Variable_name Value
auto_increment_increment 3
auto_increment_offset 1
auto_increment_increment 1
auto_increment_offset 2
wsrep_auto_increment_control OFF
SET GLOBAL wsrep_auto_increment_control='ON';
drop table t1;
2 changes: 2 additions & 0 deletions mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[mysqld.1]
auto_increment_offset=1
auto_increment_increment=1

[mysqld.2]
auto_increment_offset=2
auto_increment_increment=1
73 changes: 39 additions & 34 deletions mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
##

--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/force_restart.inc

--connection node_1
SET GLOBAL auto_increment_offset=1;
--connection node_2
SET GLOBAL auto_increment_offset=2;

--let $node_1=node_1
--let $node_2=node_2
Expand All @@ -22,23 +27,24 @@ SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';

CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

show variables like 'auto_increment%';
insert into t1(i) values(null);

select * from t1;
select * from t1 order by i;

insert into t1(i) values(null), (null), (null);

select * from t1;
select * from t1 order by i;

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
--source include/wait_condition.inc
select * from t1;
show variables like 'auto_increment%';
select * from t1 order by i;

SET GLOBAL wsrep_forced_binlog_format='none';

Expand Down Expand Up @@ -72,36 +78,31 @@ SET SESSION auto_increment_increment = 3;
SET SESSION auto_increment_offset = 1;

CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

show variables like 'auto_increment%';
insert into t1(i) values(null);

select * from t1;
select * from t1 order by i;

insert into t1(i) values(null), (null), (null);

select * from t1;
select * from t1 order by i;

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
--source include/wait_condition.inc
show variables like 'auto_increment%';

select * from t1;
select * from t1 order by i;

--connection node_1

##
## Verify the return to automatic calculation of the step
## and offset of the auto-increment:
##

SET GLOBAL wsrep_auto_increment_control='ON';

SET SESSION binlog_format='ROW';

--source include/auto_increment_offset_restore.inc
--connection node_1
show variables like 'binlog_format';
show variables like '%auto_increment%';

Expand All @@ -119,7 +120,8 @@ show variables like '%auto_increment%';
##

SET GLOBAL wsrep_auto_increment_control='ON';

--source include/auto_increment_offset_restore.inc
--connection node_1
drop table t1;

##
Expand All @@ -134,24 +136,25 @@ SET GLOBAL wsrep_forced_binlog_format='ROW';
SET GLOBAL wsrep_forced_binlog_format='ROW';

CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

show variables like 'auto_increment%';
insert into t1(i) values(null);

select * from t1;
select * from t1 order by i;

insert into t1(i) values(null), (null), (null);

select * from t1;
select * from t1 order by i;

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
--source include/wait_condition.inc

select * from t1;
show variables like 'auto_increment%';
select * from t1 order by i;

SET GLOBAL wsrep_forced_binlog_format='none';

Expand Down Expand Up @@ -181,24 +184,25 @@ SET SESSION auto_increment_increment = 3;
SET SESSION auto_increment_offset = 1;

CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text',
PRIMARY KEY (i)
i int(11) NOT NULL primary key AUTO_INCREMENT,
c char(32) DEFAULT 'dummy_text'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

show variables like 'auto_increment%';
insert into t1(i) values(null);

select * from t1;
select * from t1 order by i;

insert into t1(i) values(null), (null), (null);

select * from t1;
select * from t1 order by i;

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
--source include/wait_condition.inc
show variables like 'auto_increment%';

select * from t1;
select * from t1 order by i;

--connection node_1

Expand All @@ -208,6 +212,7 @@ select * from t1;
##

SET GLOBAL wsrep_auto_increment_control='ON';
--source include/auto_increment_offset_restore.inc

show variables like 'binlog_format';
show variables like '%auto_increment%';
Expand Down

0 comments on commit 66d93a8

Please sign in to comment.