-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug#28606948: BACKPORT OF BUG#24670909 TO 5.7.22
Backported the changes from mysql-8.0 to mysql-5.7 BUG#24670909: Problem: Previously, a session disconnect causes DROP TEMPORARY TABLE IF EXISTS to be binlogged for all the opened temp tables in that session. Even though temporary table operation are not otherwise binlogged in row or mixed mode, this was done regardless of binary log format in use, as it was not tracked, whether a particular temp table was not created in STATEMENT mode - in which case it does need the DROP. For ROW/MIXED users, this behavior causes spurious binlog writes and GTIDs generated on otherwise read only servers. Fix: Track the binlog format at temporary table create time (open_table_uncached and after final decide_logging_format call for CREATE ... SELECT), and that can be used to decide whether a DROP should be logged or not in method close_temporary_tables.
- Loading branch information
Neha Kumari
committed
Nov 1, 2018
1 parent
2348605
commit 9827f13
Showing
18 changed files
with
423 additions
and
75 deletions.
There are no files selected for viewing
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
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
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
22 changes: 22 additions & 0 deletions
22
mysql-test/suite/binlog/r/binlog_drop_temp_table_on_disconnect_row_mix.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,22 @@ | ||
RESET MASTER; | ||
CREATE TABLE t1(a INT) ENGINE=InnoDB; | ||
CREATE TABLE t2(a INT) ENGINE=MyISAM; | ||
SET @saved_binlog_format= @@SESSION.binlog_format; | ||
SET SESSION binlog_format= 'STATEMENT'; | ||
CREATE TEMPORARY TABLE tmp10 (a INT); | ||
SET SESSION binlog_format= @saved_binlog_format; | ||
CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1; | ||
CREATE TEMPORARY TABLE tmp2 ENGINE=MyISAM SELECT * FROM t2; | ||
CREATE TEMPORARY TABLE tmp3 ENGINE=MyISAM SELECT * FROM t1; | ||
CREATE TEMPORARY TABLE tmp4 ENGINE=InnoDB SELECT * FROM t2; | ||
CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB; | ||
CREATE TEMPORARY TABLE tmp6 (a INT) ENGINE=MyISAM; | ||
CREATE TEMPORARY TABLE tmp7 LIKE t1; | ||
CREATE TEMPORARY TABLE tmp8 LIKE t2; | ||
include/show_binlog_events.inc | ||
Log_name Pos Event_type Server_id End_log_pos Info | ||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(a INT) ENGINE=InnoDB | ||
master-bin.000001 # Query # # use `test`; CREATE TABLE t2(a INT) ENGINE=MyISAM | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp10 (a INT) | ||
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `tmp10` | ||
DROP TABLE t1, t2; |
28 changes: 28 additions & 0 deletions
28
mysql-test/suite/binlog/r/binlog_drop_temp_table_on_disconnect_stmt.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,28 @@ | ||
RESET MASTER; | ||
CREATE TABLE t1(a INT) ENGINE=InnoDB; | ||
CREATE TABLE t2(a INT) ENGINE=MyISAM; | ||
CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1; | ||
CREATE TEMPORARY TABLE tmp2 ENGINE=MyISAM SELECT * FROM t2; | ||
CREATE TEMPORARY TABLE tmp3 ENGINE=MyISAM SELECT * FROM t1; | ||
CREATE TEMPORARY TABLE tmp4 ENGINE=InnoDB SELECT * FROM t2; | ||
CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB; | ||
CREATE TEMPORARY TABLE tmp6 (a INT) ENGINE=MyISAM; | ||
CREATE TEMPORARY TABLE tmp7 LIKE t1; | ||
CREATE TEMPORARY TABLE tmp8 LIKE t2; | ||
SET SESSION binlog_format= 'ROW'; | ||
CREATE TEMPORARY TABLE tmp10 (a INT); | ||
include/show_binlog_events.inc | ||
Log_name Pos Event_type Server_id End_log_pos Info | ||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(a INT) ENGINE=InnoDB | ||
master-bin.000001 # Query # # use `test`; CREATE TABLE t2(a INT) ENGINE=MyISAM | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1 | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 ENGINE=MyISAM SELECT * FROM t2 | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp3 ENGINE=MyISAM SELECT * FROM t1 | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp4 ENGINE=InnoDB SELECT * FROM t2 | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp6 (a INT) ENGINE=MyISAM | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp7 LIKE t1 | ||
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp8 LIKE t2 | ||
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `tmp7`,`tmp5`,`tmp4`,`tmp1` | ||
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `tmp8`,`tmp6`,`tmp3`,`tmp2` | ||
DROP TABLE t1, t2; |
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
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
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
60 changes: 60 additions & 0 deletions
60
mysql-test/suite/binlog/t/binlog_drop_temp_table_on_disconnect_row_mix.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,60 @@ | ||
# ====== Purpose ======= | ||
# | ||
# This test verifies that DROP for a temporary table created | ||
# in Row mode is not logged in binlog at session disconnect. | ||
# | ||
# ====== Implementation ====== | ||
# | ||
# Create temporary tables in Row mode using different engines, | ||
# also create a temporary table in Statement mode, now when you connect to the session | ||
# after a disconnect print the output of show binlog events. | ||
# This will verify that the DROP for temporary table created in statement | ||
# mode is written to binary log at session disconnect, but for the temporary table | ||
# created in Row mode no DROP statement for temporary table is logged at session | ||
# disconnect. | ||
# | ||
# ====== References ======= | ||
# | ||
# Bug#28606948:BACKPORT OF BUG #24670909 TO 5.7.22 | ||
# | ||
# The name of this file has row_mix even though we are just testing in row | ||
# format because we want the name of tests to be consistent in 5.7 and 8.0 | ||
|
||
--source include/have_log_bin.inc | ||
--source include/have_myisam.inc | ||
--source include/have_binlog_format_row.inc | ||
|
||
RESET MASTER; | ||
|
||
CREATE TABLE t1(a INT) ENGINE=InnoDB; | ||
CREATE TABLE t2(a INT) ENGINE=MyISAM; | ||
|
||
--source include/count_sessions.inc | ||
|
||
--connect(con1,localhost,root) | ||
|
||
SET @saved_binlog_format= @@SESSION.binlog_format; | ||
# A DROP for tmp10 should be binlogged because CREATE TABLE is | ||
# created in Statement mode | ||
|
||
SET SESSION binlog_format= 'STATEMENT'; | ||
CREATE TEMPORARY TABLE tmp10 (a INT); | ||
SET SESSION binlog_format= @saved_binlog_format; | ||
|
||
# No DROP should be logged for any of the statements below | ||
CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1; | ||
CREATE TEMPORARY TABLE tmp2 ENGINE=MyISAM SELECT * FROM t2; | ||
CREATE TEMPORARY TABLE tmp3 ENGINE=MyISAM SELECT * FROM t1; | ||
CREATE TEMPORARY TABLE tmp4 ENGINE=InnoDB SELECT * FROM t2; | ||
CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB; | ||
CREATE TEMPORARY TABLE tmp6 (a INT) ENGINE=MyISAM; | ||
CREATE TEMPORARY TABLE tmp7 LIKE t1; | ||
CREATE TEMPORARY TABLE tmp8 LIKE t2; | ||
|
||
--disconnect con1 | ||
--connection default | ||
--source include/wait_until_count_sessions.inc | ||
|
||
--source include/show_binlog_events.inc | ||
|
||
DROP TABLE t1, t2; |
Oops, something went wrong.