mirror of
https://github.com/MariaDB/server.git
synced 2025-11-02 02:53:04 +03:00
transaction BUG#52616 Temp table prevents switch binlog format from STATEMENT to ROW Before the WL#2687 and BUG#46364, every non-transactional change that happened after a transactional change was written to trx-cache and flushed upon committing the transaction. WL#2687 and BUG#46364 changed this behavior and non-transactional changes are now written to the binary log upon committing the statement. A binary log event is identified as transactional or non-transactional through a flag in the Log_event which is set taking into account the underlie storage engine on what it is stems from. In the current bug, this flag was not being set properly when the DROP TEMPORARY TABLE was executed. However, while fixing this bug we figured out that changes to temporary tables should be always written to the trx-cache if there is an on-going transaction. Otherwise, binlog events in the reversed order would be produced. Regarding concurrency, keeping changes to temporary tables in the trx-cache is also safe as temporary tables are only visible to the owner connection. In this patch, we classify the following statements as unsafe: 1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp 2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam 3 - CREATE TEMPORARY TABLE t_myisam_temp SELECT * FROM t_myisam On the other hand, the following statements are classified as safe: 1 - INSERT INTO t_innodb SELECT * FROM t_myisam_temp 2 - INSERT INTO t_myisam_temp SELECT * FROM t_innodb The patch also guarantees that transactions that have a DROP TEMPORARY are always written to the binary log regardless of the mode and the outcome: commit or rollback. In particular, the DROP TEMPORARY is extended with the IF EXISTS clause when the current statement logging format is set to row. Finally, the patch allows to switch from STATEMENT to MIXED/ROW when there are temporary tables but the contrary is not possible.
67 lines
1.6 KiB
Plaintext
67 lines
1.6 KiB
Plaintext
|
|
--source include/have_ndb.inc
|
|
--source include/ndb_master-slave.inc
|
|
--source include/have_binlog_format_mixed_or_row.inc
|
|
|
|
--disable_query_log
|
|
--disable_warnings
|
|
connection slave;
|
|
STOP SLAVE;
|
|
connection master;
|
|
DROP TABLE IF EXISTS t1;
|
|
RESET MASTER;
|
|
connection slave;
|
|
DROP TABLE IF EXISTS t1;
|
|
RESET SLAVE;
|
|
START SLAVE;
|
|
--enable_warnings
|
|
--enable_query_log
|
|
|
|
--echo **** On Master ****
|
|
connection master;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
|
|
INSERT INTO t1 VALUES (1,1), (2,2);
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Slave ****
|
|
# This is silly, but NDB doesn't add to the binlog fast enough
|
|
--real_sleep 10
|
|
sync_slave_with_master;
|
|
INSERT INTO t1 VALUE (3,3);
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Master ****
|
|
connection master;
|
|
TRUNCATE TABLE t1;
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Slave ****
|
|
sync_slave_with_master;
|
|
# Should be empty
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Master ****
|
|
connection master;
|
|
DROP TABLE t1;
|
|
--source include/show_binlog_events.inc
|
|
|
|
--echo **** On Master ****
|
|
connection master;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
|
|
INSERT INTO t1 VALUES (1,1), (2,2);
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Slave ****
|
|
sync_slave_with_master;
|
|
INSERT INTO t1 VALUE (3,3);
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Master ****
|
|
connection master;
|
|
DELETE FROM t1;
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Slave ****
|
|
sync_slave_with_master;
|
|
# Should be empty
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
--echo **** On Master ****
|
|
connection master;
|
|
DROP TABLE t1;
|
|
--source include/show_binlog_events.inc
|
|
|
|
-- source include/master-slave-end.inc
|