随笔:MYSQL_BIN_LOG::COND_done 是什么

一、问题

image.png

是什么

欢迎关注我的《深入理解MySQL主从原理 32讲 》,如下:

image.png

二、找到影响位置

整个寻找过程应该找到key_BINLOG_COND_done这个取值,然后去看他是在那里被定义到相应的mutex/cond上,然后查找mutex/cond的作用即可。

  • 定义:
    static PSI_cond_info all_server_conds[]=
    {
    { &key_PAGE_cond, “PAGE::cond”, 0},
    { &key_COND_active, “TC_LOG_MMAP::COND_active”, 0},
    { &key_COND_pool, “TC_LOG_MMAP::COND_pool”, 0},
    { &key_BINLOG_COND_done, “MYSQL_BIN_LOG::COND_done”, 0},
    { &key_BINLOG_update_cond, “MYSQL_BIN_LOG::update_cond”, 0},

  • 注册:
    register_cond_class

  • 初始化:

MYSQL_BIN_LOG::set_psi_keys

  • 建立条件变量:

Stage_manager::init

  • 使用:

  */
  if (!leader) //如果不是 leader
  {
    mysql_mutex_lock(&m_lock_done);//加锁
    while (thd->get_transaction()->m_flags.pending) //唤醒时 设置每个事物的状态 为ture
      mysql_cond_wait(&m_cond_done, &m_lock_done);//释放锁 等待条件满足 pending=false
    mysql_mutex_unlock(&m_lock_done);//解锁 
  }

  • 栈帧

Breakpoint 2, MYSQL_BIN_LOG::set_psi_keys (this=0x2e83640, key_LOCK_index=7, key_LOCK_commit=3, key_LOCK_commit_queue=4, key_LOCK_done=5, key_LOCK_flush_queue=6, 
    key_LOCK_log=8, key_LOCK_binlog_end_pos=9, key_LOCK_sync=10, key_LOCK_sync_queue=11, key_LOCK_xids=12, key_COND_done=4, key_update_cond=5, key_prep_xids_cond=6, 
    key_file_log=2, key_file_log_index=4, key_file_log_cache=3, key_file_log_index_cache=5) at /mysqldata/percona-server-locks-detail-5.7.22/sql/binlog.h:539
539         m_key_COND_done= key_COND_done;
(gdb) bt
#0  MYSQL_BIN_LOG::set_psi_keys (this=0x2e83640, key_LOCK_index=7, key_LOCK_commit=3, key_LOCK_commit_queue=4, key_LOCK_done=5, key_LOCK_flush_queue=6, 
    key_LOCK_log=8, key_LOCK_binlog_end_pos=9, key_LOCK_sync=10, key_LOCK_sync_queue=11, key_LOCK_xids=12, key_COND_done=4, key_update_cond=5, key_prep_xids_cond=6, 
    key_file_log=2, key_file_log_index=4, key_file_log_cache=3, key_file_log_index_cache=5) at /mysqldata/percona-server-locks-detail-5.7.22/sql/binlog.h:539
#1  0x0000000000edcee4 in init_common_variables () at /mysqldata/percona-server-locks-detail-5.7.22/sql/mysqld.cc:2974
#2  0x0000000000ee117f in mysqld_main (argc=82, argv=0x2f26738) at /mysqldata/percona-server-locks-detail-5.7.22/sql/mysqld.cc:4938
#3  0x0000000000ed8504 in main (argc=4, argv=0x7fffffffe3f8) at /mysqldata/percona-server-locks-detail-5.7.22/sql/main.cc:25
建立条件变量
Breakpoint 3, Stage_manager::init (this=0x2e84858, key_LOCK_flush_queue=6, key_LOCK_sync_queue=11, key_LOCK_commit_queue=4, key_LOCK_done=5, key_COND_done=4)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/binlog.h:156
156         mysql_mutex_init(key_LOCK_done, &m_lock_done, MY_MUTEX_INIT_FAST);
(gdb) bt
#0  Stage_manager::init (this=0x2e84858, key_LOCK_flush_queue=6, key_LOCK_sync_queue=11, key_LOCK_commit_queue=4, key_LOCK_done=5, key_COND_done=4)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/binlog.h:156
#1  0x000000000187cbea in MYSQL_BIN_LOG::init_pthread_objects (this=0x2e83640) at /mysqldata/percona-server-locks-detail-5.7.22/sql/binlog.cc:3601
#2  0x0000000000edcef3 in init_common_variables () at /mysqldata/percona-server-locks-detail-5.7.22/sql/mysqld.cc:2983
#3  0x0000000000ee117f in mysqld_main (argc=82, argv=0x2f26738) at /mysqldata/percona-server-locks-detail-5.7.22/sql/mysqld.cc:4938
#4  0x0000000000ed8504 in main (argc=4, argv=0x7fffffffe3f8) at /mysqldata/percona-server-locks-detail-5.7.22/sql/main.cc:25

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2653864/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7728585/viewspace-2653864/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值