Commit f36f9d00 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi
Browse files

Fixed bug in wait_for_update() that I had introduced.

Changed option variables to my_bool (to avoid bugs in my_getopt())
Added new thread specific mutex LOCK_delete to be able to free LOCK_thread_count early.
Changed usage of LOCK_thread_count -> LOCK_status for statistics variables
parent 4ab6d8c4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -384,7 +384,6 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
  (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_server_id, MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
+2 −0
Original line number Diff line number Diff line
@@ -343,6 +343,7 @@ SLAVE_MYPID="$MYRUN_DIR/slave.pid"
SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/slave.log"
SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/slave.err"

CURRENT_TEST="$MYSQL_TEST_DIR/var/log/current_test"
SMALL_SERVER="-O key_buffer_size=1M -O sort_buffer=256K -O max_heap_table_size=1M"

export MASTER_MYPORT
@@ -1034,6 +1035,7 @@ run_testcase ()
 master_init_script=$TESTDIR/$tname-master.sh
 slave_init_script=$TESTDIR/$tname-slave.sh
 slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
 echo $tname > $CURRENT_TEST
 SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
 if [ $USE_MANAGER = 1 ] ; then
  many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
drop table if exists t1,t2;
create table t2(n int);
create table t1(n int not null auto_increment primary key);
insert into t1 values (NULL),(NULL);
+0 −1
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
# COM_BINLOG_DUMP and additionally limits the number of events per dump

source include/master-slave.inc;
drop table if exists t1,t2;

create table t2(n int);
create table t1(n int not null auto_increment primary key);
+12 −7
Original line number Diff line number Diff line
@@ -810,12 +810,8 @@ void MYSQL_LOG::new_file(bool need_lock)
    if (log_type == LOG_BIN)
    {
      if (generate_new_name(new_name, name))
      {
	/* Error;  Continue using old log file */
	if (need_lock)
	  VOID(pthread_mutex_unlock(&LOCK_log));
	return;					// Something went wrong
      }
	goto end;	/* Error;  Continue using old log file */

      new_name_ptr=new_name;
      if (!no_auto_events)
      {
@@ -853,6 +849,7 @@ void MYSQL_LOG::new_file(bool need_lock)
       no_auto_events);
  my_free(old_name,MYF(0));

end:
  if (need_lock)
  {
    pthread_mutex_unlock(&LOCK_index);
@@ -1358,14 +1355,22 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,

  NOTES
    One must have a lock on LOCK_log before calling this function.
    This lock will be freed before return!

    The reason for the above is that for enter_cond() / exit_cond() to
    work the mutex must be got before enter_cond() but releases before
    exit_cond().
    If you don't do it this way, you will get a deadlock in THD::awake()
*/


void MYSQL_LOG:: wait_for_update(THD* thd)
{
  safe_mutex_assert_owner(&LOCK_log);
  const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log,
					"Slave: waiting for binlog update");
  pthread_cond_wait(&update_cond, &LOCK_log);
  pthread_mutex_unlock(&LOCK_log);		// See NOTES
  thd->exit_cond(old_msg);
}

Loading