forked from percona/percona-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug#21317739: APPLYING CREATE TEMPORARY TABLE SQL ON A SLAVE
WITH REPLICATE-REWRITE-DB FAILS Problem: ======= As part of fix for BUG#16290902, at the time of writing the 'DROP TEMPORARY TABLE IF EXISTS' query into the binlog, the query will not be preceded by a 'use `db`' statement. The query will have a fully qualified table name. Eg: 'USE `db`; DROP TEMPORARY TABLE IF EXISTS `t1`;' will be logged as 'DROP TEMPORARY TABLE IF EXISTS `db`.`t1`;'. Because of this change application of 'replicate-rewrite-db' filter rule will fail on slave, as it works only on default database specified in 'use' statement. This causes slave to break when the 'CREATE TEMPORARY TABLE' is re-executed on slave. Analysis: ======== The intention of BUG#16290902 fix was to address a specific scenario where the default database does not exist on the slave but in spite of that DROP TEMPORARY TABLE IF EXITS query will be binlogged with 'USE default_db' statement. Which causes point in time recovery to fail when user uses Slave's binary log to re-apply. But the fix that was more generic. It completely removed 'USE default_db' for DROP TEMPORARY TABLE IF EXITS queries even when they have their default databases present. Hence the scope of the fix should have been narrowed. Fix: === At the time writing 'DROP TEMPORARY TABLE IF EXISTS' query into the binary log, check if the default database exists. If it exists then write 'USE default_db' in the binary log. If default database is not present then log the query with qualified table name.
- Loading branch information
Sujatha Sivakumar
committed
Nov 27, 2015
1 parent
3e07a42
commit 907a7cc
Showing
21 changed files
with
402 additions
and
269 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
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
43 changes: 43 additions & 0 deletions
43
mysql-test/suite/rpl/r/rpl_drop_temp_tbl_with_rewrite_db.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,43 @@ | ||
include/master-slave.inc | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
[connection master] | ||
[connection slave] | ||
CREATE DATABASE new_test; | ||
[connection master] | ||
use test; | ||
CREATE TEMPORARY TABLE t1(id int); | ||
include/sync_slave_sql_with_master.inc | ||
include/show_binlog_events.inc | ||
Log_name Pos Event_type Server_id End_log_pos Info | ||
slave-bin.000001 # Query # # CREATE DATABASE new_test | ||
slave-bin.000001 # Query # # use `new_test`; CREATE TEMPORARY TABLE t1(id int) | ||
SHOW STATUS LIKE 'Slave_open_temp_tables'; | ||
Variable_name Value | ||
Slave_open_temp_tables 1 | ||
[connection master] | ||
use test; | ||
DROP TEMPORARY TABLE IF EXISTS t1; | ||
include/sync_slave_sql_with_master.inc | ||
include/show_binlog_events.inc | ||
Log_name Pos Event_type Server_id End_log_pos Info | ||
slave-bin.000001 # Query # # CREATE DATABASE new_test | ||
slave-bin.000001 # Query # # use `new_test`; CREATE TEMPORARY TABLE t1(id int) | ||
slave-bin.000001 # Query # # use `new_test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ | ||
SHOW STATUS LIKE 'Slave_open_temp_tables'; | ||
Variable_name Value | ||
Slave_open_temp_tables 0 | ||
[connection master] | ||
use test; | ||
CREATE TEMPORARY TABLE t1(id int); | ||
include/sync_slave_sql_with_master.inc | ||
SHOW STATUS LIKE 'Slave_open_temp_tables'; | ||
Variable_name Value | ||
Slave_open_temp_tables 1 | ||
[connection slave] | ||
SHOW STATUS LIKE 'Slave_open_temp_tables'; | ||
Variable_name Value | ||
Slave_open_temp_tables 0 | ||
DROP DATABASE new_test; | ||
include/rpl_end.inc |
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
Oops, something went wrong.