Commit 04723cf7 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi
Browse files

Give better error from reconnect()

Fixed hang in start_slave_threads() when thread dies quickly.
parent 3b81549d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -50380,6 +50380,8 @@ Fixed some problems with @code{CREATE TABLE ... SELECT function()}.
@code{mysqld} now has the option @code{--temp-pool} enabled by default as this
gives better performance with some operating systems.
@item
Fixed hang in @code{CHANGE MASTER TO} if the slave thread died very quickly.
@item
Big cleanup in replication code (less logging, better error messages, etc..)
@item
If the @code{--code-file} option is specified, the server calls
+11 −10
Original line number Diff line number Diff line
@@ -1054,9 +1054,10 @@ int do_let(struct st_query* q)

int do_rpl_probe(struct st_query* q __attribute__((unused)))
{
  DBUG_ENTER("do_rpl_probe");
  if (mysql_rpl_probe(&cur_con->mysql))
    die("Failed in mysql_rpl_probe(): %s", mysql_error(&cur_con->mysql));
  return 0;
    die("Failed in mysql_rpl_probe(): '%s'", mysql_error(&cur_con->mysql));
  DBUG_RETURN(0);
}

int do_enable_rpl_parse(struct st_query* q __attribute__((unused)))
+18 −11
Original line number Diff line number Diff line
@@ -1160,14 +1160,15 @@ static void expand_error(MYSQL* mysql, int error)
static int get_master(MYSQL* mysql, MYSQL_RES* res, MYSQL_ROW row)
{
  MYSQL* master;
  DBUG_ENTER("get_master");
  if (mysql_num_fields(res) < 3)
    return 1; /* safety */
    DBUG_RETURN(1); /* safety */

  /* use the same username and password as the original connection */
  if (!(master = spawn_init(mysql, row[0], atoi(row[2]), 0, 0)))
    return 1;
    DBUG_RETURN(1);
  mysql->master = master;
  return 0;
  DBUG_RETURN(0);
}


@@ -1183,18 +1184,19 @@ static int get_slaves_from_master(MYSQL* mysql)
  int error = 1;
  int has_auth_info;
  int port_ind;
  DBUG_ENTER("get_slaves_from_master");

  if (!mysql->net.vio && !mysql_real_connect(mysql,0,0,0,0,0,0,0))
  {
    expand_error(mysql, CR_PROBE_MASTER_CONNECT);
    return 1;
    DBUG_RETURN(1);
  }

  if (mysql_query(mysql, "SHOW SLAVE HOSTS") ||
      !(res = mysql_store_result(mysql)))
  {
    expand_error(mysql, CR_PROBE_SLAVE_HOSTS);
    return 1;
    DBUG_RETURN(1);
  }

  switch (mysql_num_fields(res)) {
@@ -1238,7 +1240,7 @@ static int get_slaves_from_master(MYSQL* mysql)
err:
  if (res)
   mysql_free_result(res);
  return error;
  DBUG_RETURN(error);
}


@@ -1247,6 +1249,8 @@ int STDCALL mysql_rpl_probe(MYSQL* mysql)
  MYSQL_RES *res= 0;
  MYSQL_ROW row;
  int error = 1;
  DBUG_ENTER("mysql_rpl_probe");

  /*
    First determine the replication role of the server we connected to
    the most reliable way to do this is to run SHOW SLAVE STATUS and see
@@ -1259,7 +1263,7 @@ int STDCALL mysql_rpl_probe(MYSQL* mysql)
      !(res = mysql_store_result(mysql)))
  {
    expand_error(mysql, CR_PROBE_SLAVE_STATUS);
    return 1;
    DBUG_RETURN(1);
  }

  row= mysql_fetch_row(res);
@@ -1284,7 +1288,7 @@ int STDCALL mysql_rpl_probe(MYSQL* mysql)
err:
  if (res)
    mysql_free_result(res);
  return error;
  DBUG_RETURN(error);
}


@@ -1979,7 +1983,11 @@ static my_bool mysql_reconnect(MYSQL *mysql)
  if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
			  mysql->db, mysql->port, mysql->unix_socket,
			  mysql->client_flag))
  {
    mysql->net.last_errno= tmp_mysql.net.last_errno;
    strmov(mysql->net.last_error, tmp_mysql.net.last_error);
    DBUG_RETURN(1);
  }
  tmp_mysql.free_me=mysql->free_me;
  mysql->free_me=0;
  mysql_close(mysql);
@@ -2060,7 +2068,7 @@ mysql_close(MYSQL *mysql)
      mysql->status=MYSQL_STATUS_READY; /* Force command */
      mysql->reconnect=0;
      simple_command(mysql,COM_QUIT,NullS,0,1);
      end_server(mysql);
      end_server(mysql);			/* Sets mysql->net.vio= 0 */
    }
    my_free((gptr) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR));
    my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
@@ -2082,7 +2090,6 @@ mysql_close(MYSQL *mysql)
    /* Clear pointers for better safety */
    mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
    bzero((char*) &mysql->options,sizeof(mysql->options));
    mysql->net.vio = 0;

    /* free/close slave list */
    if (mysql->rpl_pivot)
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ a
testing temporary tables part 2
show slave status;
Master_Host	Master_User	Master_Port	Connect_retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Exec_master_log_pos	Relay_log_space
127.0.0.1	root	MASTER_PORT	60	master-bin.006	838	slave-relay-bin.004	1816	master-bin.006	Yes	Yes			0		0	838	1816
127.0.0.1	root	MASTER_PORT	60	master-bin.006	838	slave-relay-bin.001	8034	master-bin.006	Yes	Yes			0		0	838	8034
lock tables t3 read;
select count(*) from t3 where n >= 4;
count(*)
+2 −1
Original line number Diff line number Diff line
@@ -9,13 +9,14 @@ sync_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
change master to master_log_pos=73;
sleep 5;
slave stop;

change master to master_log_pos=73;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
slave start;
sleep 2;
sleep 5;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
change master to master_log_pos=173;
Loading