Skip to content

Commit

Permalink
MDEV-26833 Missed statement rollback in case transaction drops or cre…
Browse files Browse the repository at this point in the history
…ate temporary table

When transaction creates or drops temporary tables and afterward its statement
faces an error even the transactional table statement's cached ROW
format events get involved into binlog and are visible after the transaction's commit.

Fixed with proper analysis of whether the errored-out statement needs
to be rolled back in binlog.
For instance a fact of already cached CREATE or DROP for temporary
tables by previous statements alone
does not cause to retain the being errored-out statement events in the
cache.
Conversely, if the statement creates or drops a temporary table
itself it can't be rolled back - this rule remains.
  • Loading branch information
andrelkin committed Nov 5, 2021
1 parent e571eaa commit 561b6c7
Show file tree
Hide file tree
Showing 9 changed files with 1,211 additions and 51 deletions.
2 changes: 1 addition & 1 deletion mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if (`SELECT HEX(@commands) = HEX('configure')`)
--eval CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam

#
# Creates a Temporary N-table that is never dropped.
# Creates a Temporary T-table that is never dropped.
#
--eval CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb

Expand Down
62 changes: 60 additions & 2 deletions mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,65 @@ SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te R';
SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

--echo # > MDEV-26833
--echo # Errored out and rolled back Te statement should not produce any event to binlog
--echo # in the following cases:

SET @sav_var = @@session.binlog_direct_non_transactional_updates;

SET @@session.binlog_direct_non_transactional_updates = ON;
SET @commands= 'B T Drop-Temp-TT-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-T-Temp B T Create-T-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T N-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

SET @commands= 'B T Drop-Temp-TT-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-T-Temp B T Create-T-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T N-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

--echo # Non-transactional side effects.
SET @commands= 'B T N-Temp Te Ne C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T N-Temp Te Ne R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

SET @@session.binlog_direct_non_transactional_updates = OFF;
SET @commands= 'B T Drop-Temp-TT-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-T-Temp B T Create-T-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T N-Temp Te C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

SET @commands= 'B T Drop-Temp-TT-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-T-Temp B T Create-T-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T N-Temp Te R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

--echo # Non-transactional side effects.
SET @commands= 'B T N-Temp Te Ne C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T N-Temp Te Ne R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc

SET @@session.binlog_direct_non_transactional_updates = @sav_var;
--echo # < MDEV-26833

--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
Expand All @@ -495,8 +554,7 @@ if (`select @@session.binlog_format != 'STATEMENT'`)
{
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-temporary-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-temporary-slave.sql
# uncomment when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y from mysql-5.6 is merged
#--diff_files $MYSQLD_DATADIR/test-temporary-master.sql $MYSQLD_DATADIR/test-temporary-slave.sql
--diff_files $MYSQLD_DATADIR/test-temporary-master.sql $MYSQLD_DATADIR/test-temporary-slave.sql
}

--echo #########################################################################
Expand Down
Loading

0 comments on commit 561b6c7

Please sign in to comment.