~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to sql/slave.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2003 MySQL AB
 
1
/*
 
2
   Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
 
17
19
/**
97
99
registration on master",
98
100
    "Reconnecting after a failed registration on master",
99
101
    "failed registering on master, reconnecting to try again, \
100
 
log '%s' at postion %s",
 
102
log '%s' at position %s",
101
103
    "COM_REGISTER_SLAVE",
102
104
    "Slave I/O thread killed during or after reconnect"
103
105
  },
105
107
    "Waiting to reconnect after a failed binlog dump request",
106
108
    "Slave I/O thread killed while retrying master dump",
107
109
    "Reconnecting after a failed binlog dump request",
108
 
    "failed dump request, reconnecting to try again, log '%s' at postion %s",
 
110
    "failed dump request, reconnecting to try again, log '%s' at position %s",
109
111
    "COM_BINLOG_DUMP",
110
112
    "Slave I/O thread killed during or after reconnect"
111
113
  },
114
116
    "Slave I/O thread killed while waiting to reconnect after a failed read",
115
117
    "Reconnecting after a failed master event read",
116
118
    "Slave I/O thread: Failed reading log event, reconnecting to retry, \
117
 
log '%s' at postion %s",
 
119
log '%s' at position %s",
118
120
    "",
119
121
    "Slave I/O thread killed during or after a reconnect done to recover from \
120
122
failed read"
408
410
  int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
409
411
  pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
410
412
 
 
413
  if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))
 
414
  {
 
415
    DBUG_PRINT("info",("Terminating SQL thread"));
 
416
    mi->rli.abort_slave=1;
 
417
    if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock,
 
418
                                      &mi->rli.stop_cond,
 
419
                                      &mi->rli.slave_running,
 
420
                                      skip_lock)) &&
 
421
        !force_all)
 
422
      DBUG_RETURN(error);
 
423
  }
411
424
  if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
412
425
  {
413
426
    DBUG_PRINT("info",("Terminating IO thread"));
419
432
        !force_all)
420
433
      DBUG_RETURN(error);
421
434
  }
422
 
  if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))
423
 
  {
424
 
    DBUG_PRINT("info",("Terminating SQL thread"));
425
 
    mi->rli.abort_slave=1;
426
 
    if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock,
427
 
                                      &mi->rli.stop_cond,
428
 
                                      &mi->rli.slave_running,
429
 
                                      skip_lock)) &&
430
 
        !force_all)
431
 
      DBUG_RETURN(error);
432
 
  }
433
435
  DBUG_RETURN(0);
434
436
}
435
437
 
596
598
      DBUG_PRINT("sleep",("Waiting for slave thread to start"));
597
599
      const char* old_msg = thd->enter_cond(start_cond,cond_lock,
598
600
                                            "Waiting for slave thread to start");
599
 
      pthread_cond_wait(start_cond,cond_lock);
 
601
      pthread_cond_wait(start_cond, cond_lock);
600
602
      thd->exit_cond(old_msg);
601
603
      pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
602
604
      if (thd->killed)
 
605
      {
 
606
        if (start_lock)
 
607
          pthread_mutex_unlock(start_lock);
603
608
        DBUG_RETURN(thd->killed_errno());
 
609
      }
604
610
    }
605
611
  }
606
612
  if (start_lock)
2529
2535
 
2530
2536
  thd= new THD; // note that contructor of THD uses DBUG_ !
2531
2537
  THD_CHECK_SENTRY(thd);
 
2538
  DBUG_ASSERT(mi->io_thd == 0);
2532
2539
  mi->io_thd = thd;
2533
2540
 
2534
2541
  pthread_detach_this_thread();
3398
3405
    Rotate the relay log makes binlog format detection easier (at next slave
3399
3406
    start or mysqlbinlog)
3400
3407
  */
3401
 
  rotate_relay_log(mi); /* will take the right mutexes */
3402
 
  DBUG_RETURN(0);
 
3408
  DBUG_RETURN(rotate_relay_log(mi) /* will take the right mutexes */);
3403
3409
}
3404
3410
 
3405
3411
/*
4482
4488
  is void).
4483
4489
*/
4484
4490
 
4485
 
void rotate_relay_log(Master_info* mi)
 
4491
int rotate_relay_log(Master_info* mi)
4486
4492
{
4487
4493
  DBUG_ENTER("rotate_relay_log");
4488
4494
  Relay_log_info* rli= &mi->rli;
4489
 
 
4490
 
  /* We don't lock rli->run_lock. This would lead to deadlocks. */
4491
 
  pthread_mutex_lock(&mi->run_lock);
 
4495
  int error= 0;
4492
4496
 
4493
4497
  /*
4494
4498
     We need to test inited because otherwise, new_file() will attempt to lock
4501
4505
  }
4502
4506
 
4503
4507
  /* If the relay log is closed, new_file() will do nothing. */
4504
 
  rli->relay_log.new_file();
 
4508
  if ((error= rli->relay_log.new_file()))
 
4509
    goto end;
4505
4510
 
4506
4511
  /*
4507
4512
    We harvest now, because otherwise BIN_LOG_HEADER_SIZE will not immediately
4518
4523
  */
4519
4524
  rli->relay_log.harvest_bytes_written(&rli->log_space_total);
4520
4525
end:
4521
 
  pthread_mutex_unlock(&mi->run_lock);
4522
 
  DBUG_VOID_RETURN;
 
4526
  DBUG_RETURN(error);
4523
4527
}
4524
4528
 
4525
4529