mysql 怎么复制代码_mysql学习笔记4---mysql 复制---源代码

mysql:

c:底层

C++:相对上层

主备复制:主库通知备库来取

MYSQL复制源代码代码:SQL文件夹intstart_slave_thread(

#ifdef HAVE_PSI_INTERFACE

PSI_thread_key thread_key,#endifpthread_handler h_func, mysql_mutex_t*start_lock,

mysql_mutex_t*cond_lock,

mysql_cond_t*start_cond,volatile uint *slave_running,volatile ulong *slave_run_id,

Master_info*mi)

{

pthread_t th;ulongstart_id;interror;

DBUG_ENTER("start_slave_thread");if(start_lock)

mysql_mutex_lock(start_lock);if (!server_id)

{if(start_cond)

mysql_cond_broadcast(start_cond);if(start_lock)

mysql_mutex_unlock(start_lock);

sql_print_error("Server id not set, will not start slave");

DBUG_RETURN(ER_BAD_SLAVE);

}if (*slave_running)

{if(start_cond)

mysql_cond_broadcast(start_cond);if(start_lock)

mysql_mutex_unlock(start_lock);

DBUG_RETURN(ER_SLAVE_MUST_STOP);

}

start_id= *slave_run_id;

DBUG_PRINT("info",("Creating new slave thread"));if ((error=mysql_thread_create(thread_key,&th, &connection_attrib, h_func, (void*)mi)))

{

sql_print_error("Can't create slave thread (errno= %d).", error);if(start_lock)

mysql_mutex_unlock(start_lock);

DBUG_RETURN(ER_SLAVE_THREAD);

}if (start_cond && cond_lock) //caller has cond_lock

{

THD* thd =current_thd;while (start_id == *slave_run_id && thd !=NULL)

{

DBUG_PRINT("sleep",("Waiting for slave thread to start"));

PSI_stage_info saved_st

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值