mirror of
https://github.com/MariaDB/server.git
synced 2025-08-26 01:44:06 +03:00
BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a
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.
This commit is contained in:
@@ -22,7 +22,7 @@ SET AUTOCOMMIT = 1;
|
||||
BEGIN;
|
||||
UPDATE t SET f = 'yellow 2' WHERE i = 3;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional and non-transactional tables and write to any of them are unsafe.
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional (or a temporary table of any engine type) and non-transactional tables and write to any of them are unsafe.
|
||||
SET AUTOCOMMIT = 1;
|
||||
BEGIN;
|
||||
UPDATE t SET f = 'magenta 2' WHERE f = 'red';
|
||||
@@ -51,7 +51,7 @@ SET AUTOCOMMIT = 1;
|
||||
BEGIN;
|
||||
UPDATE t SET f = 'gray 2' WHERE i = 3;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional and non-transactional tables and write to any of them are unsafe.
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional (or a temporary table of any engine type) and non-transactional tables and write to any of them are unsafe.
|
||||
SET AUTOCOMMIT = 1;
|
||||
BEGIN;
|
||||
UPDATE t SET f = 'dark blue 2' WHERE f = 'red';
|
||||
@@ -77,7 +77,7 @@ master-bin.000001 # Xid # # COMMIT /* XID */
|
||||
SET AUTOCOMMIT = 0;
|
||||
UPDATE t SET f = 'yellow 1' WHERE i = 3;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional and non-transactional tables and write to any of them are unsafe.
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional (or a temporary table of any engine type) and non-transactional tables and write to any of them are unsafe.
|
||||
SET AUTOCOMMIT = 0;
|
||||
UPDATE t SET f = 'magenta 1' WHERE f = 'red';
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
@@ -104,7 +104,7 @@ master-bin.000001 # Query # # ROLLBACK
|
||||
SET AUTOCOMMIT = 0;
|
||||
UPDATE t SET f = 'gray 1' WHERE i = 3;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional and non-transactional tables and write to any of them are unsafe.
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statements that read from both transactional (or a temporary table of any engine type) and non-transactional tables and write to any of them are unsafe.
|
||||
SET AUTOCOMMIT = 0;
|
||||
UPDATE t SET f = 'dark blue 1' WHERE f = 'red';
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
|
Reference in New Issue
Block a user