Commit d2e6fe02 authored by Monty's avatar Monty Committed by Sergei Golubchik

Generate a warning(note) and write to error log if master_pos_wait() fails.

This is to make it easier to understand why master_pos_wait() fails in mtr.
parent 153c9173
...@@ -69,6 +69,8 @@ set @@default_master_connection=''; ...@@ -69,6 +69,8 @@ set @@default_master_connection='';
select master_pos_wait('master-bin.999999',0,2); select master_pos_wait('master-bin.999999',0,2);
master_pos_wait('master-bin.999999',0,2) master_pos_wait('master-bin.999999',0,2)
-1 -1
Warnings:
Note 1105 Timeout waiting for master-bin.999999:4. Current pos is master-bin.000001:329
set @@default_master_connection=''; set @@default_master_connection='';
# #
# checking variables # checking variables
......
...@@ -4,6 +4,8 @@ connection slave; ...@@ -4,6 +4,8 @@ connection slave;
select master_pos_wait('master-bin.999999',0,2); select master_pos_wait('master-bin.999999',0,2);
master_pos_wait('master-bin.999999',0,2) master_pos_wait('master-bin.999999',0,2)
-1 -1
Warnings:
Note 1105 Timeout waiting for master-bin.999999:4. Current pos is master-bin.000001:329
explain extended select master_pos_wait('master-bin.999999',0,2); explain extended select master_pos_wait('master-bin.999999',0,2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -16,6 +18,8 @@ include/wait_for_slave_sql_to_stop.inc ...@@ -16,6 +18,8 @@ include/wait_for_slave_sql_to_stop.inc
connection slave; connection slave;
master_pos_wait('master-bin.999999',0) master_pos_wait('master-bin.999999',0)
NULL NULL
Warnings:
Note 1105 master_pos_wait() was aborted because slave is not running
connection master; connection master;
"*** must be empty ***" "*** must be empty ***"
show slave status; show slave status;
...@@ -34,6 +38,8 @@ include/start_slave.inc ...@@ -34,6 +38,8 @@ include/start_slave.inc
select master_pos_wait('master-bin.000001',1000000,1); select master_pos_wait('master-bin.000001',1000000,1);
master_pos_wait('master-bin.000001',1000000,1) master_pos_wait('master-bin.000001',1000000,1)
-1 -1
Warnings:
Note 1105 Timeout waiting for master-bin.000001:1000000. Current pos is master-bin.000001:329
set default_master_connection = ''; set default_master_connection = '';
# Call for non-existing anonymous connection -- works (expected NULL) # Call for non-existing anonymous connection -- works (expected NULL)
select master_pos_wait('master-bin.000001',1000000,1); select master_pos_wait('master-bin.000001',1000000,1);
...@@ -43,6 +49,8 @@ NULL ...@@ -43,6 +49,8 @@ NULL
select master_pos_wait('master-bin.000001',1000000,1,"my_slave"); select master_pos_wait('master-bin.000001',1000000,1,"my_slave");
master_pos_wait('master-bin.000001',1000000,1,"my_slave") master_pos_wait('master-bin.000001',1000000,1,"my_slave")
-1 -1
Warnings:
Note 1105 Timeout waiting for master-bin.000001:1000000. Current pos is master-bin.000001:329
STOP SLAVE 'my_slave'; STOP SLAVE 'my_slave';
RESET SLAVE 'my_slave' ALL; RESET SLAVE 'my_slave' ALL;
change master to master_port=MASTER_MYPORT, master_host='127.0.0.1', master_user='root'; change master to master_port=MASTER_MYPORT, master_host='127.0.0.1', master_user='root';
......
...@@ -3931,8 +3931,10 @@ longlong Item_master_pos_wait::val_int() ...@@ -3931,8 +3931,10 @@ longlong Item_master_pos_wait::val_int()
connection_name= thd->variables.default_master_connection; connection_name= thd->variables.default_master_connection;
if (!(mi= get_master_info(&connection_name, Sql_condition::WARN_LEVEL_WARN))) if (!(mi= get_master_info(&connection_name, Sql_condition::WARN_LEVEL_WARN)))
{
sql_print_information("Could not get master info for %s", connection_name.str);
goto err; goto err;
}
if ((event_count = mi->rli.wait_for_pos(thd, log_name, pos, timeout)) == -2) if ((event_count = mi->rli.wait_for_pos(thd, log_name, pos, timeout)) == -2)
{ {
null_value = 1; null_value = 1;
......
...@@ -937,6 +937,11 @@ int Relay_log_info::wait_for_pos(THD* thd, String* log_name, ...@@ -937,6 +937,11 @@ int Relay_log_info::wait_for_pos(THD* thd, String* log_name,
DBUG_PRINT("info",("Got signal of master update or timed out")); DBUG_PRINT("info",("Got signal of master update or timed out"));
if (error == ETIMEDOUT || error == ETIME) if (error == ETIMEDOUT || error == ETIME)
{ {
my_printf_error(ER_UNKNOWN_ERROR,
"Timeout waiting for %s:%llu. Current pos is %s:%llu",
MYF(ME_ERROR_LOG | ME_NOTE),
log_name_tmp, (ulonglong) log_pos,
group_master_log_name, (ulonglong) group_master_log_pos);
error= -1; error= -1;
break; break;
} }
...@@ -957,6 +962,17 @@ improper_arguments: %d timed_out: %d", ...@@ -957,6 +962,17 @@ improper_arguments: %d timed_out: %d",
if (thd->killed || init_abort_pos_wait != abort_pos_wait || if (thd->killed || init_abort_pos_wait != abort_pos_wait ||
!slave_running) !slave_running)
{ {
const char *cause= 0;
if (init_abort_pos_wait != abort_pos_wait)
cause= "CHANGE MASTER detected";
else if (!slave_running)
cause="slave is not running";
else
cause="connection was killed";
my_printf_error(ER_UNKNOWN_ERROR,
"master_pos_wait() was aborted because %s",
MYF(ME_ERROR_LOG | ME_NOTE),
cause);
error= -2; error= -2;
} }
DBUG_RETURN( error ? error : event_count ); DBUG_RETURN( error ? error : event_count );
......
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