MDEV-9266 Creating index on temporaray table breaks replication
Problem:- Create/drop index was logged into binlog. Goal:- Operation on temporary table should not be binlog when binlog format is row. Solution:- We should add CF_FORCE_ORIGINAL_BINLOG_FORMAT when there is ddl on temp table. For optimize, analyze, repair we wont change anything ,Then will be logged in binlog , But they also dont throw any error if operation fails Since slave wont be having any temp table , but these operation on tmp table will be processed without breaking replication. For rename we need a different logic MDEV-16728 will solve it.
This commit is contained in:
parent
e5c26fdfab
commit
ada54101a7
31
mysql-test/suite/binlog/include/check_binlog_size.inc
Normal file
31
mysql-test/suite/binlog/include/check_binlog_size.inc
Normal file
@ -0,0 +1,31 @@
|
||||
# This file runs the query and checks
|
||||
# whether the size of binlog is increased or not
|
||||
# If size is changed it issue die command
|
||||
# Parameters
|
||||
# $sql_query = query to run
|
||||
|
||||
#Only last row of show binlog events matter
|
||||
--let $tmp= 0
|
||||
--let $counter= 1
|
||||
while ($tmp != "No such row")
|
||||
{
|
||||
--let $initial_binlog_size= $tmp
|
||||
--let $tmp= query_get_value(show binary logs, File_size, $counter)
|
||||
--inc $counter
|
||||
}
|
||||
|
||||
--eval $sql_query
|
||||
|
||||
--let $tmp= 0
|
||||
--let $counter= 1
|
||||
while ($tmp != "No such row")
|
||||
{
|
||||
--let $current_binlog_size= $tmp
|
||||
--let $tmp= query_get_value(show binary logs, File_size, $counter)
|
||||
--inc $counter
|
||||
}
|
||||
|
||||
if ($initial_binlog_size != $current_binlog_size)
|
||||
{
|
||||
die "Binlog size changed";
|
||||
}
|
7
mysql-test/suite/binlog/r/binlog_tmp_table_row.result
Normal file
7
mysql-test/suite/binlog/r/binlog_tmp_table_row.result
Normal file
@ -0,0 +1,7 @@
|
||||
RESET MASTER;
|
||||
#Create table test
|
||||
create temporary table t1(a int, b int);
|
||||
#Add index test
|
||||
create index index_a on t1(a);
|
||||
#drop index test
|
||||
drop index index_a on t1;
|
30
mysql-test/suite/binlog/t/binlog_tmp_table_row.test
Normal file
30
mysql-test/suite/binlog/t/binlog_tmp_table_row.test
Normal file
@ -0,0 +1,30 @@
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# Test if statements used temporary tables are not binlogged in the case of
|
||||
# binlog_format=row
|
||||
#
|
||||
# ==== Method ====
|
||||
#
|
||||
# We will see if binlog file size is increased or not, It should be constant for the
|
||||
# entire period of test.
|
||||
#
|
||||
# ==== Related bugs ====
|
||||
#
|
||||
# Mdev-9266
|
||||
#
|
||||
source include/have_log_bin.inc;
|
||||
source include/have_binlog_format_row.inc;
|
||||
|
||||
RESET MASTER;
|
||||
|
||||
--echo #Create table test
|
||||
--let $sql_query= create temporary table t1(a int, b int)
|
||||
--source suite/binlog/include/check_binlog_size.inc
|
||||
|
||||
--echo #Add index test
|
||||
--let $sql_query= create index index_a on t1(a)
|
||||
--source suite/binlog/include/check_binlog_size.inc
|
||||
|
||||
--echo #drop index test
|
||||
--let $sql_query= drop index index_a on t1
|
||||
--source suite/binlog/include/check_binlog_size.inc
|
@ -457,6 +457,9 @@ void init_update_queries(void)
|
||||
sql_command_flags[SQLCOM_TRUNCATE]|= CF_FORCE_ORIGINAL_BINLOG_FORMAT;
|
||||
/* We don't want to replicate DROP for temp tables in row format */
|
||||
sql_command_flags[SQLCOM_DROP_TABLE]|= CF_FORCE_ORIGINAL_BINLOG_FORMAT;
|
||||
/* We don't want to replicate CREATE/DROP INDEX for temp tables in row format */
|
||||
sql_command_flags[SQLCOM_CREATE_INDEX]|= CF_FORCE_ORIGINAL_BINLOG_FORMAT;
|
||||
sql_command_flags[SQLCOM_DROP_INDEX]|= CF_FORCE_ORIGINAL_BINLOG_FORMAT;
|
||||
/* One can change replication mode with SET */
|
||||
sql_command_flags[SQLCOM_SET_OPTION]|= CF_FORCE_ORIGINAL_BINLOG_FORMAT;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user