Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-9401: wsrep_forced_binlog_format with binlog causes crash
Some statements are always replicated in STATEMENT binlog format. So upon their execution, the current binlog format is temporarily switched to STATEMENT even though the session's format is different. This state, stored in THD's current_stmt_binlog_format, was getting incorrectly masked by wsrep_forced_binlog_format, causing assertions and unintended generation of row events. Backported galera.galera_forced_binlog_format and added a test specific to this case.
- Loading branch information
Nirbhay Choubey
committed
Mar 18, 2016
1 parent
3042d65
commit 9c89b84
Showing
4 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
mysql-test/suite/galera/r/galera_forced_binlog_format.result
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,40 @@ | ||
RESET MASTER; | ||
SET SESSION binlog_format = 'STATEMENT'; | ||
Warnings: | ||
Warning 1105 MariaDB Galera does not support binlog format: STATEMENT | ||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
INSERT INTO t1 VALUES (1); | ||
SET SESSION binlog_format = 'MIXED'; | ||
Warnings: | ||
Warning 1105 MariaDB Galera does not support binlog format: MIXED | ||
INSERT INTO t1 VALUES (2); | ||
SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 245; | ||
Log_name Pos Event_type Server_id End_log_pos Info | ||
mysqld-bin.000001 <Pos> Query 1 <End_log_pos> use `test`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB | ||
mysqld-bin.000001 <Pos> Query 1 <End_log_pos> BEGIN | ||
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1) | ||
mysqld-bin.000001 <Pos> Write_rows 1 <End_log_pos> table_id: ### flags: STMT_END_F | ||
mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */ | ||
mysqld-bin.000001 <Pos> Query 1 <End_log_pos> BEGIN | ||
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1) | ||
mysqld-bin.000001 <Pos> Write_rows 1 <End_log_pos> table_id: ### flags: STMT_END_F | ||
mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */ | ||
DROP TABLE t1; | ||
# | ||
# MDEV-9401: wsrep_forced_binlog_format with binlog causes crash | ||
# | ||
SET SESSION binlog_format = 'ROW'; | ||
CREATE DATABASE testdb_9401; | ||
USE testdb_9401; | ||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
CREATE USER dummy@localhost; | ||
GRANT ALL PRIVILEGES ON testdb_9401.t1 TO dummy@localhost; | ||
FLUSH PRIVILEGES; | ||
SHOW GRANTS FOR dummy@localhost; | ||
Grants for dummy@localhost | ||
GRANT USAGE ON *.* TO 'dummy'@'localhost' | ||
GRANT ALL PRIVILEGES ON `testdb_9401`.`t1` TO 'dummy'@'localhost' | ||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost; | ||
DROP USER dummy@localhost; | ||
DROP DATABASE testdb_9401; | ||
# End of tests |
1 change: 1 addition & 0 deletions
1
mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt
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 @@ | ||
--log-bin --wsrep_forced_binlog_format=ROW |
45 changes: 45 additions & 0 deletions
45
mysql-test/suite/galera/t/galera_forced_binlog_format.test
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,45 @@ | ||
# | ||
# Test that wsrep_forced_binlog_format=ROW indeed prevents the log to be switched to STATEMENT format on a per-connection basis | ||
# | ||
|
||
--source include/have_log_bin.inc | ||
--source include/have_innodb.inc | ||
--source include/galera_cluster.inc | ||
|
||
--connection node_1 | ||
RESET MASTER; | ||
|
||
SET SESSION binlog_format = 'STATEMENT'; | ||
|
||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
INSERT INTO t1 VALUES (1); | ||
|
||
SET SESSION binlog_format = 'MIXED'; | ||
|
||
INSERT INTO t1 VALUES (2); | ||
|
||
--replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ | ||
--replace_column 2 <Pos> 5 <End_log_pos> | ||
SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 245; | ||
|
||
DROP TABLE t1; | ||
|
||
--echo # | ||
--echo # MDEV-9401: wsrep_forced_binlog_format with binlog causes crash | ||
--echo # | ||
SET SESSION binlog_format = 'ROW'; | ||
CREATE DATABASE testdb_9401; | ||
USE testdb_9401; | ||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
CREATE USER dummy@localhost; | ||
GRANT ALL PRIVILEGES ON testdb_9401.t1 TO dummy@localhost; | ||
FLUSH PRIVILEGES; | ||
SHOW GRANTS FOR dummy@localhost; | ||
# Cleanup | ||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost; | ||
DROP USER dummy@localhost; | ||
DROP DATABASE testdb_9401; | ||
|
||
--source include/galera_end.inc | ||
--echo # End of tests | ||
|
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