Skip to content

Commit

Permalink
MDEV-11177 mysqlbinlog exits silently without error when another
Browse files Browse the repository at this point in the history
instance connects to server.

        New thread kill status added KILL_SLAVE_SAME_ID, and the related
        error message.
  • Loading branch information
Alexey Botchkov committed Mar 21, 2017
1 parent 1ca8637 commit 92f18bd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
2 changes: 2 additions & 0 deletions sql/share/errmsg-utf8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7448,3 +7448,5 @@ ER_GEOJSON_NOT_CLOSED
eng "Incorrect GeoJSON format - polygon not closed."
ER_JSON_PATH_EMPTY
eng "Path expression '$' is not allowed in argument %d to function '%s'."
ER_SLAVE_SAME_ID
eng "A slave with the same server_uuid/server_id as this slave has connected to the master"
3 changes: 3 additions & 0 deletions sql/signal_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ extern "C" sig_handler handle_fatal_signal(int sig)
case ABORT_QUERY_HARD:
kreason= "ABORT_QUERY";
break;
case KILL_SLAVE_SAME_ID:
kreason= "KILL_SLAVE_SAME_ID";
break;
}
my_safe_printf_stderr("%s", "\n"
"Trying to get some variables.\n"
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,8 @@ int killed_errno(killed_state killed)
case KILL_SERVER:
case KILL_SERVER_HARD:
DBUG_RETURN(ER_SERVER_SHUTDOWN);
case KILL_SLAVE_SAME_ID:
DBUG_RETURN(ER_SLAVE_SAME_ID);
}
DBUG_RETURN(0); // Keep compiler happy
}
Expand Down
18 changes: 12 additions & 6 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,23 @@ enum killed_state
ABORT_QUERY_HARD= 7,
KILL_TIMEOUT= 8,
KILL_TIMEOUT_HARD= 9,
/*
When binlog reading thread connects to the server it kills
all the binlog threads with the same ID.
*/
KILL_SLAVE_SAME_ID= 10,
/*
All of the following killed states will kill the connection
KILL_CONNECTION must be the first of these and it must start with
an even number (becasue of HARD bit)!
*/
KILL_CONNECTION= 10,
KILL_CONNECTION_HARD= 11,
KILL_SYSTEM_THREAD= 12,
KILL_SYSTEM_THREAD_HARD= 13,
KILL_SERVER= 14,
KILL_SERVER_HARD= 15
KILL_CONNECTION= 12,
KILL_CONNECTION_HARD= 13,
KILL_SYSTEM_THREAD= 14,
KILL_SYSTEM_THREAD_HARD= 15,
KILL_SERVER= 16,
KILL_SERVER_HARD= 17,

};

extern int killed_errno(killed_state killed);
Expand Down
12 changes: 10 additions & 2 deletions sql/sql_repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2910,6 +2910,13 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
THD_STAGE_INFO(thd, stage_waiting_to_finalize_termination);
RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags));

if (info->thd->killed == KILL_SLAVE_SAME_ID)
{
info->errmsg= "A slave with the same server_uuid/server_id as this slave "
"has connected to the master";
info->error= ER_SLAVE_SAME_ID;
}

const bool binlog_open = my_b_inited(&log);
if (file >= 0)
{
Expand All @@ -2921,7 +2928,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
thd->variables.max_allowed_packet= old_max_allowed_packet;
delete info->fdev;

if (info->error == ER_MASTER_FATAL_ERROR_READING_BINLOG && binlog_open)
if ((info->error == ER_MASTER_FATAL_ERROR_READING_BINLOG ||
info->error == ER_SLAVE_SAME_ID) && binlog_open)
{
/*
detailing the fatal error message with coordinates
Expand Down Expand Up @@ -3392,7 +3400,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
it will be slow because it will iterate through the list
again. We just to do kill the thread ourselves.
*/
tmp->awake(KILL_QUERY);
tmp->awake(KILL_SLAVE_SAME_ID);
mysql_mutex_unlock(&tmp->LOCK_thd_data);
}
}
Expand Down

0 comments on commit 92f18bd

Please sign in to comment.