From 04c5af18023014c2925c83df32f68906e706495d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Mar 2008 14:49:21 +0200 Subject: [PATCH 1/3] Bug#26622 MASTER_POS_WAIT does not work as documented MASTER_POS_WAIT return values are different than expected when the server is not a slave. It returns -1 instead of NULL. Fixed with correcting st_relay_log_info::wait_for_pos() to return the proper value in the case of rli info is not inited. mysql-test/r/rpl_master_pos_wait.result: results changed mysql-test/t/rpl_master_pos_wait.test: the new test to check that select master_pos_wait() to a server does not have master info returns NULL as specified. sql/slave.cc: changing the return value to correspond the specification. --- mysql-test/r/rpl_master_pos_wait.result | 6 ++++++ mysql-test/t/rpl_master_pos_wait.test | 11 +++++++++++ sql/slave.cc | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/rpl_master_pos_wait.result b/mysql-test/r/rpl_master_pos_wait.result index f0f48de4e07..b831eb9b95a 100644 --- a/mysql-test/r/rpl_master_pos_wait.result +++ b/mysql-test/r/rpl_master_pos_wait.result @@ -16,3 +16,9 @@ select master_pos_wait('master-bin.999999',0); stop slave sql_thread; master_pos_wait('master-bin.999999',0) NULL +"*** must be empty ***" +show slave status; +"*** must be NULL ***" +select master_pos_wait('foo', 98); +master_pos_wait('foo', 98) +NULL diff --git a/mysql-test/t/rpl_master_pos_wait.test b/mysql-test/t/rpl_master_pos_wait.test index 893c8746efc..2f7b18ae04b 100644 --- a/mysql-test/t/rpl_master_pos_wait.test +++ b/mysql-test/t/rpl_master_pos_wait.test @@ -15,4 +15,15 @@ stop slave sql_thread; connection slave; reap; +# +# bug#26622 MASTER_POS_WAIT does not work as documented +# + +connection master; +echo "*** must be empty ***"; +query_vertical show slave status; + +echo "*** must be NULL ***"; +select master_pos_wait('foo', 98); + # End of 4.1 tests diff --git a/sql/slave.cc b/sql/slave.cc index 181ad4ed8cb..d4d0655f366 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2685,7 +2685,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, longlong timeout) { if (!inited) - return -1; + return -2; int event_count = 0; ulong init_abort_pos_wait; int error=0; From 0e679ab782e6968b159bcca8cdf307e5602dd3ea Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Mar 2008 21:14:28 +0200 Subject: [PATCH 2/3] Bug #26622 MASTER_POS_WAIT does not work as documented Affected tests fixing. After the fix for st_relay_log_info::wait_for_pos() that handles widely used select('master-bin.xxxx',pos) invoked by mysqltest there appeared to be four tests that either tried synchronizing when the slave was stopped or used incorrect synchronization method like to call `sync_with_master' from the current connection being to the master itself. Fixed with correcting the current connection or/and using the correct synchronization macro when possible. mysql-test/r/rpl_loaddata.result: results changed mysql-test/r/rpl_slave_status.result: results changed mysql-test/t/rpl_loaddata.test: fixing cleanup for two tests mysql-test/t/rpl_skip_error.test: fixing cleanup for two tests mysql-test/t/rpl_slave_status.test: fixing cleanup mysql-test/t/rpl_temporary.test: fixing synchronizations to use the intended correct macro. --- mysql-test/r/rpl_loaddata.result | 3 ++- mysql-test/r/rpl_slave_status.result | 1 + mysql-test/t/rpl_loaddata.test | 13 +++++++++++-- mysql-test/t/rpl_skip_error.test | 5 +++-- mysql-test/t/rpl_slave_status.test | 6 +++++- mysql-test/t/rpl_temporary.test | 5 +++-- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index be137079c7a..e704ada657b 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -77,7 +77,8 @@ load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 1 -drop table t2; +set @@global.sql_slave_skip_counter=1; +start slave; drop table t2; drop table t1; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; diff --git a/mysql-test/r/rpl_slave_status.result b/mysql-test/r/rpl_slave_status.result index 9a4ec4131b0..641a65f5ed7 100644 --- a/mysql-test/r/rpl_slave_status.result +++ b/mysql-test/r/rpl_slave_status.result @@ -53,3 +53,4 @@ Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master NULL drop table t1; +drop table t1; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index a4781ed4faa..ee80bdfde45 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -147,12 +147,20 @@ terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; connection slave; wait_for_slave_to_stop; -drop table t2; + +# cleanup: + +set @@global.sql_slave_skip_counter=1; +start slave; + connection master; drop table t2; drop table t1; +sync_slave_with_master; + # BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed +connection master; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; --error 1062 @@ -160,5 +168,6 @@ LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; DROP TABLE t1; -sync_with_master; +sync_slave_with_master; + # End of 4.1 tests diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test index baa7a88b8bb..0e3fd5d9e0d 100644 --- a/mysql-test/t/rpl_skip_error.test +++ b/mysql-test/t/rpl_skip_error.test @@ -15,12 +15,13 @@ select * from t1; connection master; drop table t1; -sync_with_master; +sync_slave_with_master; # End of 4.1 tests # # #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists # +connection master; create table t1(a int primary key); insert into t1 values (1),(2); delete from t1 where @@server_id=1; @@ -36,5 +37,5 @@ select * from t1; show slave status; connection master; drop table t1; -sync_with_master; +sync_slave_with_master; # End of 5.0 tests diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test index b97b769d181..527e230854a 100644 --- a/mysql-test/t/rpl_slave_status.test +++ b/mysql-test/t/rpl_slave_status.test @@ -29,8 +29,12 @@ start slave; --vertical_results show slave status; +# cleanup: slave io thread has been stopped "irrecoverably" +# so we clean up mess manually + connection master; drop table t1; -sync_with_master; +connection slave; +drop table t1; # end of 4.1 tests diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index a7a15aebe7a..516f3a026c9 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -130,7 +130,7 @@ drop table t1,t2; # don't get any memory leaks for this create temporary table t3 (f int); -sync_with_master; +sync_slave_with_master; # The server will now close done @@ -141,7 +141,8 @@ sync_with_master; connection master; create temporary table t4 (f int); create table t5 (f int); -sync_with_master; +sync_slave_with_master; +connection master; # find dumper's $id source include/get_binlog_dump_thread_id.inc; insert into t4 values (1); From 4597814717f4ae503923ad5ea7aacae3a95b6435 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2008 17:52:57 +0100 Subject: [PATCH 3/3] Post-merge fixes. mysql-test/extra/rpl_tests/rpl_loaddata.test: Removing SHOW MASTER STATUS that does not seem to make sense. mysql-test/extra/rpl_tests/rpl_log.test: Correcting test case to sync slave with master. mysql-test/suite/binlog/r/binlog_unsafe.result: Result change. mysql-test/suite/binlog/t/binlog_unsafe.test: Removing unsafe variable from list of safe variables. mysql-test/suite/rpl/r/rpl_loaddata.result: Result change. mysql-test/suite/rpl/r/rpl_skip_error.result: Result change. mysql-test/suite/rpl/t/rpl_skip_error.test: Correcting bad manual+automatic merge. Test is now only relevant for statement- based replication. sql/rpl_rli.cc: Correcting automerge undoing previous change of return value. Relay_log_info::wait_for_pos() should return -2 when not initialized to work correctly. --- mysql-test/extra/rpl_tests/rpl_loaddata.test | 7 --- mysql-test/extra/rpl_tests/rpl_log.test | 2 +- .../suite/binlog/r/binlog_unsafe.result | 2 - mysql-test/suite/binlog/t/binlog_unsafe.test | 1 - mysql-test/suite/rpl/r/rpl_loaddata.result | 6 +- mysql-test/suite/rpl/r/rpl_skip_error.result | 62 ++++++++++++++++++- mysql-test/suite/rpl/t/rpl_skip_error.test | 21 +++++-- sql/rpl_rli.cc | 2 +- 8 files changed, 78 insertions(+), 25 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index bb6afd73034..8f32ee674f8 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -39,13 +39,6 @@ sync_with_master; select * from t1; select * from t3; -# We want to be sure that LOAD DATA is in the slave's binlog. -# But we can't simply read this binlog, because as the slave has not been -# restarted for this test, the file_id is uncertain (would cause test -# failures). So instead, we test if the binlog looks long enough to -# contain LOAD DATA. Since 5.0.3 we assume that binlog of 1292 is ok. -# If LOAD DATA was not logged, the binlog would be shorter. -show master status; connection master; diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index a5db4dfab4d..078d3d4557d 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -148,5 +148,5 @@ drop table t1; # End of 4.1 tests -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index 1c155cd0876..a384364b730 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -153,7 +153,6 @@ INSERT INTO t1 VALUES (@@session.pseudo_thread_id); INSERT INTO t1 VALUES (@@session.foreign_key_checks); INSERT INTO t1 VALUES (@@session.sql_auto_is_null); INSERT INTO t1 VALUES (@@session.unique_checks); -INSERT INTO t2 VALUES (@@session.sql_mode); INSERT INTO t1 VALUES (@@session.auto_increment_increment); INSERT INTO t1 VALUES (@@session.auto_increment_offset); INSERT INTO t2 VALUES (@@session.character_set_client); @@ -179,4 +178,3 @@ DROP PROCEDURE proc4; DROP FUNCTION func5; DROP PREPARE prep6; DROP TABLE t1, t2, t3, trigger_table, trigger_table2; -DROP VIEW v1; diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 5aa20a6947d..1baab141b44 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -200,7 +200,6 @@ INSERT INTO t1 VALUES (@@session.pseudo_thread_id); INSERT INTO t1 VALUES (@@session.foreign_key_checks); INSERT INTO t1 VALUES (@@session.sql_auto_is_null); INSERT INTO t1 VALUES (@@session.unique_checks); -INSERT INTO t2 VALUES (@@session.sql_mode); INSERT INTO t1 VALUES (@@session.auto_increment_increment); INSERT INTO t1 VALUES (@@session.auto_increment_offset); INSERT INTO t2 VALUES (@@session.character_set_client); diff --git a/mysql-test/suite/rpl/r/rpl_loaddata.result b/mysql-test/suite/rpl/r/rpl_loaddata.result index 6bca1708297..070c50db3d5 100644 --- a/mysql-test/suite/rpl/r/rpl_loaddata.result +++ b/mysql-test/suite/rpl/r/rpl_loaddata.result @@ -26,9 +26,6 @@ day id category name 2003-02-22 2461 b a a a @ %  ' " a 2003-03-22 2161 c asdf 2003-03-22 2416 a bbbbb -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -slave-bin.000001 1280 drop table t1; drop table t2; drop table t3; @@ -83,8 +80,7 @@ load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 'day' -set @@global.sql_slave_skip_counter=1; -start slave; +drop table t2; drop table t2; drop table t1; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; diff --git a/mysql-test/suite/rpl/r/rpl_skip_error.result b/mysql-test/suite/rpl/r/rpl_skip_error.result index 0421df81b42..b90d8113e8e 100644 --- a/mysql-test/suite/rpl/r/rpl_skip_error.result +++ b/mysql-test/suite/rpl/r/rpl_skip_error.result @@ -13,18 +13,18 @@ insert into t1 values (1); insert into t1 values (1); insert into t1 values (2),(3); [on slave] -select * from t1 ORDER BY n; +select * from t1 order by n; n 1 2 3 ==== Test With sql_mode=strict_trans_tables ==== -insert into t1 values (7), (8); +insert into t1 values (7),(8); [on master] set sql_mode=strict_trans_tables; insert into t1 values (7), (8), (9); [on slave] -select * from t1; +select * from t1 order by n; n 1 2 @@ -72,3 +72,59 @@ Last_SQL_Errno 0 Last_SQL_Error ==== Clean Up ==== drop table t1; +create table t1(a int primary key); +insert into t1 values (1),(2); +delete from t1 where @@server_id=1; +Warnings: +Warning 1592 Statement is not safe to log in statement format. +set sql_mode=strict_trans_tables; +insert into t1 values (7), (8), (9); +[on slave] +select * from t1; +a +1 +2 +7 +8 +9 +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos # +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running Yes +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table # +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos # +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # +Master_SSL_Verify_Server_Cert No +Last_IO_Errno # +Last_IO_Error # +Last_SQL_Errno 0 +Last_SQL_Error +==== Clean Up ==== +drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test index a608c111701..cac797d3797 100644 --- a/mysql-test/suite/rpl/t/rpl_skip_error.test +++ b/mysql-test/suite/rpl/t/rpl_skip_error.test @@ -18,7 +18,7 @@ # bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic source include/master-slave.inc; -source include/have_binlog_format_mixed_or_statement.inc; +source include/have_binlog_format_statement.inc; --echo ==== Test Without sql_mode=strict_trans_tables ==== @@ -37,11 +37,22 @@ insert into t1 values (1); # These should work fine insert into t1 values (2),(3); -save_master_pos; -connection slave; -sync_with_master; -select * from t1; +sync_slave_with_master; +--echo [on slave] +select * from t1 order by n; +--echo ==== Test With sql_mode=strict_trans_tables ==== +insert into t1 values (7),(8); +--echo [on master] +connection master; +set sql_mode=strict_trans_tables; +insert into t1 values (7), (8), (9); +--echo [on slave] +sync_slave_with_master; +select * from t1 order by n; +source include/show_slave_status2.inc; + +--echo ==== Clean Up ==== connection master; drop table t1; sync_slave_with_master; diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 03f790b934f..bd8246b066f 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -615,7 +615,7 @@ int Relay_log_info::wait_for_pos(THD* thd, String* log_name, DBUG_ENTER("Relay_log_info::wait_for_pos"); if (!inited) - DBUG_RETURN(-1); + DBUG_RETURN(-2); DBUG_PRINT("enter",("log_name: '%s' log_pos: %lu timeout: %lu", log_name->c_ptr(), (ulong) log_pos, (ulong) timeout));