Commit eed62d99 authored by unknown's avatar unknown

Fix for

BUG#797 "If query ignored on slave (replicate-ignore-table) the slave still checks if
the returned error (0) is the same as the one on the master, whereas it shouldn't
test this.
Plus a new test for BUG#797.


include/mysqld_error.h:
  New error code (can be sent only to the slave thread, not to normal clients).
sql/log.cc:
  removed comment from a previous debugging.
sql/log_event.cc:
  ER_SLAVE_IGNORED_TABLE is an ignorable error.
sql/share/czech/errmsg.txt:
  for BUG#797
sql/share/danish/errmsg.txt:
  for BUG#797
sql/share/dutch/errmsg.txt:
  for BUG#797
sql/share/english/errmsg.txt:
  for BUG#797
sql/share/estonian/errmsg.txt:
  for BUG#797
sql/share/french/errmsg.txt:
  for BUG#797
sql/share/german/errmsg.txt:
  for BUG#797
sql/share/greek/errmsg.txt:
  for BUG#797
sql/share/hungarian/errmsg.txt:
  for BUG#797
sql/share/italian/errmsg.txt:
  for BUG#797
sql/share/japanese/errmsg.txt:
  for BUG#797
sql/share/korean/errmsg.txt:
  for BUG#797
sql/share/norwegian-ny/errmsg.txt:
  for BUG#797
sql/share/norwegian/errmsg.txt:
  for BUG#797
sql/share/polish/errmsg.txt:
  for BUG#797
sql/share/portuguese/errmsg.txt:
  for BUG#797
sql/share/romanian/errmsg.txt:
  for BUG#797
sql/share/russian/errmsg.txt:
  for BUG#797
sql/share/slovak/errmsg.txt:
  for BUG#797
sql/share/spanish/errmsg.txt:
  for BUG#797
sql/share/swedish/errmsg.txt:
  for BUG#797
sql/share/ukrainian/errmsg.txt:
  for BUG#797
sql/sql_parse.cc:
  when in sql_parse in the slave thread we ignore the query because of replicate-do
  and replicate-ignore options, we return a specific error to the slave thread,
  so that it knows that the query has been ignored (which is different from a
  successful query).
  A small cleanup (test was done twice).
parent d0486f8a
...@@ -253,4 +253,5 @@ ...@@ -253,4 +253,5 @@
#define ER_CANT_USE_OPTION_HERE 1234 #define ER_CANT_USE_OPTION_HERE 1234
#define ER_NOT_SUPPORTED_YET 1235 #define ER_NOT_SUPPORTED_YET 1235
#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 #define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
#define ER_ERROR_MESSAGES 237 #define ER_SLAVE_IGNORED_TABLE 1237 /* only the slave SQL thread can be sent this */
#define ER_ERROR_MESSAGES 238
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
create table t1 (a int primary key);
insert into t1 values (1),(1);
Duplicate entry '1' for key 1
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254
show tables like 't1';
Tables_in_test (t1)
drop table t1;
--replicate-ignore-table=test.t1
\ No newline at end of file
# Test for
# Bug #797: If a query is ignored on slave (replicate-ignore-table) the slave
# still checks that it has the same error as on the master.
source include/master-slave.inc;
connection master;
create table t1 (a int primary key);
# generate an error that goes to the binlog
--error 1062;
insert into t1 values (1),(1);
save_master_pos;
connection slave;
# as the t1 table is ignored on the slave, the slave should be able to sync
sync_with_master;
show slave status;
# check that the table has been ignored, because otherwise the test is nonsense
show tables like 't1';
connection master;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;
...@@ -875,14 +875,9 @@ void MYSQL_LOG::new_file(bool need_lock) ...@@ -875,14 +875,9 @@ void MYSQL_LOG::new_file(bool need_lock)
save_log_type=log_type; save_log_type=log_type;
name=0; // Don't free name name=0; // Don't free name
close(); close();
/*
if (save_log_type == LOG_BIN) // TODO: at this place is_open() will see the log closed, which is BUG#791.
{
printf("after close, before open; I wait for 20 seconds\n");
sleep(20);
printf("sleep finished, opening\n");
}
*/
open(old_name, save_log_type, new_name_ptr, index_file_name, io_cache_type, open(old_name, save_log_type, new_name_ptr, index_file_name, io_cache_type,
no_auto_events, max_size); no_auto_events, max_size);
my_free(old_name,MYF(0)); my_free(old_name,MYF(0));
......
...@@ -69,7 +69,8 @@ static void pretty_print_str(FILE* file, char* str, int len) ...@@ -69,7 +69,8 @@ static void pretty_print_str(FILE* file, char* str, int len)
inline int ignored_error_code(int err_code) inline int ignored_error_code(int err_code)
{ {
return use_slave_mask && bitmap_is_set(&slave_error_mask, err_code); return ((err_code == ER_SLAVE_IGNORED_TABLE) ||
(use_slave_mask && bitmap_is_set(&slave_error_mask, err_code)));
} }
......
...@@ -247,3 +247,4 @@ ...@@ -247,3 +247,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -241,3 +241,4 @@ ...@@ -241,3 +241,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -249,3 +249,4 @@ ...@@ -249,3 +249,4 @@
"Foutieve toepassing/plaatsing van '%s'", "Foutieve toepassing/plaatsing van '%s'",
"Deze versie van MySQL ondersteunt nog geen '%s'", "Deze versie van MySQL ondersteunt nog geen '%s'",
"Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log", "Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -243,3 +243,4 @@ ...@@ -243,3 +243,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -241,3 +241,4 @@ ...@@ -241,3 +241,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -240,3 +240,4 @@ ...@@ -240,3 +240,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Uso/posizione di '%s' sbagliato", "Uso/posizione di '%s' sbagliato",
"Questa versione di MySQL non supporta ancora '%s'", "Questa versione di MySQL non supporta ancora '%s'",
"Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario", "Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -240,3 +240,4 @@ ...@@ -240,3 +240,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -240,3 +240,4 @@ ...@@ -240,3 +240,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -240,3 +240,4 @@ ...@@ -240,3 +240,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -242,3 +242,4 @@ ...@@ -242,3 +242,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -242,3 +242,4 @@ ...@@ -242,3 +242,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -240,3 +240,4 @@ ...@@ -240,3 +240,4 @@
" '%s'", " '%s'",
" MySQL '%s'", " MySQL '%s'",
" %d: '%-.128s' ", " %d: '%-.128s' ",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -246,3 +246,4 @@ ...@@ -246,3 +246,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -239,3 +239,4 @@ ...@@ -239,3 +239,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -238,3 +238,4 @@ ...@@ -238,3 +238,4 @@
"Fel använding/placering av '%s'", "Fel använding/placering av '%s'",
"Denna version av MySQL kan ännu inte utföra '%s'", "Denna version av MySQL kan ännu inte utföra '%s'",
"Fick fatalt fel %d: '%-.128s' från master vid läsning av binärloggen" "Fick fatalt fel %d: '%-.128s' från master vid läsning av binärloggen"
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -243,3 +243,4 @@ ...@@ -243,3 +243,4 @@
"Wrong usage/placement of '%s'", "Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'", "This version of MySQL doesn't yet support '%s'",
"Got fatal error %d: '%-.128s' from master when reading data from binary log", "Got fatal error %d: '%-.128s' from master when reading data from binary log",
"Slave SQL thread ignored the query because of replicate-*-table rules"
...@@ -1324,7 +1324,11 @@ mysql_execute_command(void) ...@@ -1324,7 +1324,11 @@ mysql_execute_command(void)
given and the table list says the query should not be replicated given and the table list says the query should not be replicated
*/ */
if (table_rules_on && tables && !tables_ok(thd,tables)) if (table_rules_on && tables && !tables_ok(thd,tables))
{
/* we warn the slave SQL thread */
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
/* /*
This is a workaround to deal with the shortcoming in 3.23.44-3.23.46 This is a workaround to deal with the shortcoming in 3.23.44-3.23.46
...@@ -1339,13 +1343,7 @@ mysql_execute_command(void) ...@@ -1339,13 +1343,7 @@ mysql_execute_command(void)
#endif #endif
} }
/* if (lex->select_lex.next && create_total_list(thd,lex,&tables))
Skip if we are in the slave thread, some table rules have been given
and the table list says the query should not be replicated
*/
if ((lex->select_lex.next && create_total_list(thd,lex,&tables)) ||
(table_rules_on && tables && thd->slave_thread &&
!tables_ok(thd,tables)))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
/* /*
...@@ -2330,7 +2328,10 @@ mysql_execute_command(void) ...@@ -2330,7 +2328,10 @@ mysql_execute_command(void)
if (thd->slave_thread && if (thd->slave_thread &&
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name))) !db_ok_with_wild_table(lex->name)))
{
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
break; break;
}
if (check_access(thd,CREATE_ACL,lex->name,0,1)) if (check_access(thd,CREATE_ACL,lex->name,0,1))
break; break;
...@@ -2354,7 +2355,10 @@ mysql_execute_command(void) ...@@ -2354,7 +2355,10 @@ mysql_execute_command(void)
if (thd->slave_thread && if (thd->slave_thread &&
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name))) !db_ok_with_wild_table(lex->name)))
{
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
break; break;
}
if (check_access(thd,DROP_ACL,lex->name,0,1)) if (check_access(thd,DROP_ACL,lex->name,0,1))
break; break;
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment