[Commits] cbfa5f6: MDEV-11177 mysqlbinlog exits silently without error when another

Alexey Botchkov holyfoot at askmonty.org
Mon Mar 13 16:28:48 EET 2017


revision-id: cbfa5f6a6d48b3b755462eb0df5e34c63de78f98 (mariadb-10.2.4-46-gcbfa5f6)
parent(s): eded6243bc4796ab44e70403edd059d32225f589
committer: Alexey Botchkov
timestamp: 2017-03-13 18:26:37 +0400
message:

MDEV-11177 mysqlbinlog exits silently without error when another
instance connects to server.

        New thread kill status added KILL_SLAVE_SAME_ID, and the related
        error message.

---
 sql/share/errmsg-utf8.txt |  2 ++
 sql/signal_handler.cc     |  3 +++
 sql/sql_class.cc          |  2 ++
 sql/sql_class.h           | 18 ++++++++++++------
 sql/sql_repl.cc           | 12 ++++++++++--
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 8939910..ae4dc59 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -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"
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc
index dc90fca..efcc9a3 100644
--- a/sql/signal_handler.cc
+++ b/sql/signal_handler.cc
@@ -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"
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f042e66..c3bd40c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -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
 }
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 22895d7..986cb1c 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -478,16 +478,22 @@ enum killed_state
   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);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 2a22810..0180671 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -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)
   {
@@ -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
@@ -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);
   }
 }


More information about the commits mailing list