mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Refs: MW-248
- test cases from PXC for reproducing the issue - initial fix
This commit is contained in:
committed by
Nirbhay Choubey
parent
a53ac77c42
commit
df96eb5d04
61
mysql-test/suite/galera/r/galera_as_slave_autoinc.result
Normal file
61
mysql-test/suite/galera/r/galera_as_slave_autoinc.result
Normal file
@ -0,0 +1,61 @@
|
||||
START SLAVE USER='root';
|
||||
Warnings:
|
||||
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
|
||||
SET SESSION binlog_format='STATEMENT';
|
||||
CREATE TABLE t1 (
|
||||
i int(11) NOT NULL AUTO_INCREMENT,
|
||||
c char(32) DEFAULT 'dummy_text',
|
||||
PRIMARY KEY (i)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
insert into t1(i) values(null);
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
insert into t1(i) values(null), (null), (null);
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
2 dummy_text
|
||||
3 dummy_text
|
||||
4 dummy_text
|
||||
show variables like 'binlog_format';
|
||||
Variable_name Value
|
||||
binlog_format STATEMENT
|
||||
show variables like '%auto_increment%';
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
wsrep_auto_increment_control ON
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
2 dummy_text
|
||||
3 dummy_text
|
||||
4 dummy_text
|
||||
show variables like 'binlog_format';
|
||||
Variable_name Value
|
||||
binlog_format ROW
|
||||
show variables like '%auto_increment%';
|
||||
Variable_name Value
|
||||
auto_increment_increment 2
|
||||
auto_increment_offset 1
|
||||
wsrep_auto_increment_control ON
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
2 dummy_text
|
||||
3 dummy_text
|
||||
4 dummy_text
|
||||
show variables like 'binlog_format';
|
||||
Variable_name Value
|
||||
binlog_format ROW
|
||||
show variables like '%auto_increment%';
|
||||
Variable_name Value
|
||||
auto_increment_increment 2
|
||||
auto_increment_offset 2
|
||||
wsrep_auto_increment_control ON
|
||||
DROP TABLE t1;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE ALL;
|
||||
SET GLOBAL binlog_format='ROW';
|
||||
RESET MASTER;
|
74
mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
Normal file
74
mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
Normal file
@ -0,0 +1,74 @@
|
||||
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)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
insert into t1(i) values(null);
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
insert into t1(i) values(null), (null), (null);
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
3 dummy_text
|
||||
5 dummy_text
|
||||
7 dummy_text
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
3 dummy_text
|
||||
5 dummy_text
|
||||
7 dummy_text
|
||||
SET GLOBAL wsrep_forced_binlog_format='none';
|
||||
SET GLOBAL wsrep_forced_binlog_format='none';
|
||||
drop table t1;
|
||||
SET SESSION binlog_format='STATEMENT';
|
||||
show variables like 'binlog_format';
|
||||
Variable_name Value
|
||||
binlog_format STATEMENT
|
||||
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)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
insert into t1(i) values(null);
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
insert into t1(i) values(null), (null), (null);
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
4 dummy_text
|
||||
7 dummy_text
|
||||
10 dummy_text
|
||||
select * from t1;
|
||||
i c
|
||||
1 dummy_text
|
||||
4 dummy_text
|
||||
7 dummy_text
|
||||
10 dummy_text
|
||||
SET GLOBAL wsrep_auto_increment_control='ON';
|
||||
SET SESSION binlog_format='ROW';
|
||||
show variables like 'binlog_format';
|
||||
Variable_name Value
|
||||
binlog_format ROW
|
||||
show variables like '%auto_increment%';
|
||||
Variable_name Value
|
||||
auto_increment_increment 2
|
||||
auto_increment_offset 1
|
||||
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
|
||||
wsrep_auto_increment_control OFF
|
||||
SET GLOBAL wsrep_auto_increment_control='ON';
|
||||
drop table t1;
|
1
mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf
Normal file
1
mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf
Normal file
@ -0,0 +1 @@
|
||||
!include ../galera_2nodes_as_slave.cnf
|
79
mysql-test/suite/galera/t/galera_as_slave_autoinc.test
Normal file
79
mysql-test/suite/galera/t/galera_as_slave_autoinc.test
Normal file
@ -0,0 +1,79 @@
|
||||
#
|
||||
# Test Galera as a slave to a MySQL master
|
||||
#
|
||||
# The galera/galera_2node_slave.cnf describes the setup of the nodes
|
||||
#
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_log_bin.inc
|
||||
|
||||
# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
|
||||
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
|
||||
--source include/galera_cluster.inc
|
||||
|
||||
--connection node_2
|
||||
--disable_query_log
|
||||
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
|
||||
--enable_query_log
|
||||
START SLAVE USER='root';
|
||||
|
||||
--connection node_1
|
||||
|
||||
##
|
||||
## Verify the correct operation of the auto-increment when
|
||||
## the binlog format set to the 'STATEMENT' on the master node:
|
||||
##
|
||||
|
||||
SET SESSION binlog_format='STATEMENT';
|
||||
|
||||
CREATE TABLE t1 (
|
||||
i int(11) NOT NULL AUTO_INCREMENT,
|
||||
c char(32) DEFAULT 'dummy_text',
|
||||
PRIMARY KEY (i)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
insert into t1(i) values(null);
|
||||
|
||||
select * from t1;
|
||||
|
||||
insert into t1(i) values(null), (null), (null);
|
||||
|
||||
select * from t1;
|
||||
|
||||
show variables like 'binlog_format';
|
||||
show variables like '%auto_increment%';
|
||||
|
||||
--connection node_2
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
|
||||
--source include/wait_condition.inc
|
||||
|
||||
select * from t1;
|
||||
|
||||
show variables like 'binlog_format';
|
||||
show variables like '%auto_increment%';
|
||||
|
||||
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
|
||||
|
||||
select * from t1;
|
||||
|
||||
show variables like 'binlog_format';
|
||||
show variables like '%auto_increment%';
|
||||
|
||||
--connection node_1
|
||||
DROP TABLE t1;
|
||||
|
||||
--connection node_2
|
||||
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
STOP SLAVE;
|
||||
RESET SLAVE ALL;
|
||||
|
||||
--connection node_1
|
||||
|
||||
SET GLOBAL binlog_format='ROW';
|
||||
|
||||
RESET MASTER;
|
114
mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test
Normal file
114
mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test
Normal file
@ -0,0 +1,114 @@
|
||||
##
|
||||
## Tests the auto-increment with binlog in STATEMENT mode.
|
||||
##
|
||||
|
||||
--source include/galera_cluster.inc
|
||||
--source include/have_innodb.inc
|
||||
|
||||
##
|
||||
## Verify the correct operation of the auto-increment when the binlog
|
||||
## format artificially set to the 'STATEMENT' (although this mode is
|
||||
## not recommended in the current version):
|
||||
##
|
||||
|
||||
--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)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
insert into t1(i) values(null);
|
||||
|
||||
select * from t1;
|
||||
|
||||
insert into t1(i) values(null), (null), (null);
|
||||
|
||||
select * from t1;
|
||||
|
||||
--connection node_2
|
||||
|
||||
select * from t1;
|
||||
|
||||
SET GLOBAL wsrep_forced_binlog_format='none';
|
||||
|
||||
--connection node_1
|
||||
|
||||
SET GLOBAL wsrep_forced_binlog_format='none';
|
||||
|
||||
drop table t1;
|
||||
|
||||
##
|
||||
## Check the operation when the automatic control over the auto-increment
|
||||
## settings is switched off, that is, when we use the increment step and
|
||||
## the offset specified by the user. In the current session, the binlog
|
||||
## format is set to 'STATEMENT'. It is important that the values of the
|
||||
## auto-increment options does not changed on other node - it allows us
|
||||
## to check the correct transmission of the auto-increment options to
|
||||
## other nodes:
|
||||
##
|
||||
|
||||
--disable_warnings
|
||||
SET SESSION binlog_format='STATEMENT';
|
||||
--enable_warnings
|
||||
|
||||
show variables like 'binlog_format';
|
||||
|
||||
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)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
insert into t1(i) values(null);
|
||||
|
||||
select * from t1;
|
||||
|
||||
insert into t1(i) values(null), (null), (null);
|
||||
|
||||
select * from t1;
|
||||
|
||||
--connection node_2
|
||||
|
||||
select * from t1;
|
||||
|
||||
--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';
|
||||
|
||||
show variables like 'binlog_format';
|
||||
show variables like '%auto_increment%';
|
||||
|
||||
##
|
||||
## Verify the recovery of original user-defined values after
|
||||
## stopping the automatic control over auto-increment:
|
||||
##
|
||||
|
||||
SET GLOBAL wsrep_auto_increment_control='OFF';
|
||||
|
||||
show variables like '%auto_increment%';
|
||||
|
||||
##
|
||||
## Restore original options and drop test table:
|
||||
##
|
||||
|
||||
SET GLOBAL wsrep_auto_increment_control='ON';
|
||||
|
||||
drop table t1;
|
@ -660,6 +660,7 @@ typedef struct system_variables
|
||||
uint wsrep_sync_wait;
|
||||
ulong wsrep_retry_autocommit;
|
||||
ulong wsrep_OSU_method;
|
||||
ulong wsrep_auto_increment_control;
|
||||
#endif
|
||||
double long_query_time_double;
|
||||
|
||||
|
@ -6805,8 +6805,8 @@ void THD::reset_for_next_command()
|
||||
transactions. Appliers and replayers are either processing ROW
|
||||
events or get autoinc variable values from Query_log_event.
|
||||
*/
|
||||
if (WSREP(thd) && thd->wsrep_exec_mode == LOCAL_STATE) {
|
||||
if (wsrep_auto_increment_control)
|
||||
if (WSREP(thd) && thd->wsrep_exec_mode == LOCAL_STATE &&
|
||||
!thd->slave_thread && wsrep_auto_increment_control)
|
||||
{
|
||||
if (thd->variables.auto_increment_offset !=
|
||||
global_system_variables.auto_increment_offset)
|
||||
@ -6817,7 +6817,6 @@ void THD::reset_for_next_command()
|
||||
thd->variables.auto_increment_increment=
|
||||
global_system_variables.auto_increment_increment;
|
||||
}
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
thd->query_start_used= 0;
|
||||
thd->query_start_sec_part_used= 0;
|
||||
|
Reference in New Issue
Block a user