~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/rpl_rli.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 04:28:21 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020042821-rqqdrccuu8195k3y
Second pass of thd cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
   cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
53
53
   group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0),
54
54
   last_master_timestamp(0), slave_skip_counter(0),
55
 
   abort_pos_wait(0), slave_run_id(0), sql_thd(0),
 
55
   abort_pos_wait(0), slave_run_id(0), sql_session(0),
56
56
   inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
57
57
   until_log_pos(0), retried_trans(0),
58
58
   tables_to_lock(0), tables_to_lock_count(0),
464
464
 
465
465
  SYNOPSIS
466
466
    wait_for_pos()
467
 
    thd             client thread that sent SELECT MASTER_POS_WAIT
 
467
    session             client thread that sent SELECT MASTER_POS_WAIT
468
468
    log_name        log name to wait for
469
469
    log_pos         position to wait for
470
470
    timeout         timeout in seconds before giving up waiting
483
483
                before reaching the desired log/position
484
484
 */
485
485
 
486
 
int32_t Relay_log_info::wait_for_pos(Session* thd, String* log_name,
 
486
int32_t Relay_log_info::wait_for_pos(Session* session, String* log_name,
487
487
                                    int64_t log_pos,
488
488
                                    int64_t timeout)
489
489
{
498
498
 
499
499
  set_timespec(abstime,timeout);
500
500
  pthread_mutex_lock(&data_lock);
501
 
  msg= thd->enter_cond(&data_cond, &data_lock,
 
501
  msg= session->enter_cond(&data_cond, &data_lock,
502
502
                       "Waiting for the slave SQL thread to "
503
503
                       "advance position");
504
504
  /*
550
550
  }
551
551
 
552
552
  /* The "compare and wait" main loop */
553
 
  while (!thd->killed &&
 
553
  while (!session->killed &&
554
554
         init_abort_pos_wait == abort_pos_wait &&
555
555
         slave_running)
556
556
  {
596
596
 
597
597
      pos_reached= ((!cmp_result && group_master_log_pos >= (uint64_t)log_pos) ||
598
598
                    cmp_result > 0);
599
 
      if (pos_reached || thd->killed)
 
599
      if (pos_reached || session->killed)
600
600
        break;
601
601
    }
602
602
 
633
633
  }
634
634
 
635
635
err:
636
 
  thd->exit_cond(msg);
637
 
  if (thd->killed || init_abort_pos_wait != abort_pos_wait ||
 
636
  session->exit_cond(msg);
 
637
  if (session->killed || init_abort_pos_wait != abort_pos_wait ||
638
638
      !slave_running)
639
639
  {
640
640
    error= -2;
720
720
    Assumes to have a run lock on rli and that no slave thread are running.
721
721
*/
722
722
 
723
 
int32_t purge_relay_logs(Relay_log_info* rli, Session *thd, bool just_reset,
 
723
int32_t purge_relay_logs(Relay_log_info* rli, Session *session, bool just_reset,
724
724
                     const char** errmsg)
725
725
{
726
726
  int32_t error=0;
770
770
    rli->cur_log_fd= -1;
771
771
  }
772
772
 
773
 
  if (rli->relay_log.reset_logs(thd))
 
773
  if (rli->relay_log.reset_logs(session))
774
774
  {
775
775
    *errmsg = "Failed during log reset";
776
776
    error=1;
921
921
    middle of the "transaction". START SLAVE will resume at BEGIN
922
922
    while the MyISAM table has already been updated.
923
923
  */
924
 
  if ((sql_thd->options & OPTION_BEGIN) && opt_using_transactions)
 
924
  if ((sql_session->options & OPTION_BEGIN) && opt_using_transactions)
925
925
    inc_event_relay_log_pos();
926
926
  else
927
927
  {
940
940
  }
941
941
}
942
942
 
943
 
void Relay_log_info::cleanup_context(Session *thd, bool error)
 
943
void Relay_log_info::cleanup_context(Session *session, bool error)
944
944
{
945
 
  assert(sql_thd == thd);
 
945
  assert(sql_session == session);
946
946
  /*
947
947
    1) Instances of Table_map_log_event, if ::do_apply_event() was called on them,
948
948
    may have opened tables, which we cannot be sure have been closed (because
957
957
  */
958
958
  if (error)
959
959
  {
960
 
    ha_autocommit_or_rollback(thd, 1); // if a "statement transaction"
961
 
    end_trans(thd, ROLLBACK); // if a "real transaction"
 
960
    ha_autocommit_or_rollback(session, 1); // if a "statement transaction"
 
961
    end_trans(session, ROLLBACK); // if a "real transaction"
962
962
  }
963
963
  m_table_map.clear_tables();
964
 
  close_thread_tables(thd);
 
964
  close_thread_tables(session);
965
965
  clear_tables_to_lock();
966
966
  clear_flag(IN_STMT);
967
967
  /*
968
968
    Cleanup for the flags that have been set at do_apply_event.
969
969
  */
970
 
  thd->options&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
971
 
  thd->options&= ~OPTION_RELAXED_UNIQUE_CHECKS;
 
970
  session->options&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
 
971
  session->options&= ~OPTION_RELAXED_UNIQUE_CHECKS;
972
972
  last_event_start_time= 0;
973
973
  return;
974
974
}