summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2004-03-17 10:35:03 +0100
committerunknown <guilhem@mysql.com>2004-03-17 10:35:03 +0100
commit0103d9464fa3b2b3837301f049c52e42419074ef (patch)
treec33f645c0ede61c2f00434dcae9577d092d0862d
parent4f27d6eb3fc8818e95c46399ac346d6afe8bb478 (diff)
downloadmariadb-git-0103d9464fa3b2b3837301f049c52e42419074ef.tar.gz
Fix for BUG#2922 "Crash (signal11) after "load data from master""
with a testcase. We needed to init_master_info before we flush_master_info in LOAD DATA FROM MASTER. mysql-test/r/rpl000009.result: result update mysql-test/t/rpl000009.test: adding a test for RESET SLAVE + LOAD DATA FROM MASTER sql/repl_failsafe.cc: LOAD DATA FROM MASTER udpates the master info in the slave, so needs to ensure that it is properly inited first (otherwise, after RESET SLAVE, we are flush_io_cache()ing an uninitialized IO_CACHE master.info). Note that it master info is already inited (active_mi->inited==1), init_master_info() will do nothing, which is what we want.
-rw-r--r--mysql-test/r/rpl000009.result12
-rw-r--r--mysql-test/t/rpl000009.test15
-rw-r--r--sql/repl_failsafe.cc12
3 files changed, 37 insertions, 2 deletions
diff --git a/mysql-test/r/rpl000009.result b/mysql-test/r/rpl000009.result
index 569dd301143..a4611cf7d42 100644
--- a/mysql-test/r/rpl000009.result
+++ b/mysql-test/r/rpl000009.result
@@ -111,6 +111,18 @@ n s
2 two bar
3 three bar
4 four bar
+stop slave;
+reset slave;
+load data from master;
+start slave;
+insert into bar.t1 values (5, 'five bar');
+select * from bar.t1;
+n s
+1 one bar
+2 two bar
+3 three bar
+4 four bar
+5 five bar
load table bar.t1 from master;
Table 't1' already exists
drop table bar.t1;
diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test
index e019e1fc3a7..4426cafe299 100644
--- a/mysql-test/t/rpl000009.test
+++ b/mysql-test/t/rpl000009.test
@@ -108,6 +108,21 @@ connection slave;
sync_with_master;
select * from bar.t1;
+# Check that LOAD DATA FROM MASTER is able to create master.info
+# if needed (if RESET SLAVE was used before), before writing to it (BUG#2922).
+
+stop slave;
+reset slave;
+load data from master;
+start slave;
+# see if replication coordinates were restored fine
+connection master;
+insert into bar.t1 values (5, 'five bar');
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from bar.t1;
+
# Check that LOAD DATA FROM MASTER reports the error if it can't drop a
# table to be overwritten.
# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index e687b227946..1edf452d5f6 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -874,7 +874,7 @@ int load_master_data(THD* thd)
cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
- // adjust position in the master
+ // adjust replication coordinates from the master
if (master_status_res)
{
MYSQL_ROW row = mc_mysql_fetch_row(master_status_res);
@@ -887,10 +887,18 @@ int load_master_data(THD* thd)
*/
if (row && row[0] && row[1])
{
+ /*
+ If the slave's master info is not inited, we init it, then we write
+ the new coordinates to it. Must call init_master_info() *before*
+ setting active_mi, because init_master_info() sets active_mi with
+ defaults.
+ */
+ if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0))
+ send_error(&thd->net, ER_MASTER_INFO);
strmake(active_mi->master_log_name, row[0],
sizeof(active_mi->master_log_name));
active_mi->master_log_pos = strtoull(row[1], (char**) 0, 10);
- // don't hit the magic number
+ // at least in recent versions, the condition below should be false
if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE)
active_mi->master_log_pos = BIN_LOG_HEADER_SIZE;
active_mi->rli.pending = 0;