mysqld --debug-sync

http://hedengcheng.com/?p=238https://dev.mysql.com/doc/internals/en/debug-sync-facility.html

mysqld --datadir=/data --basedir=/usr/local/mysql56 --user=mysql --gdb  --debug-sync

会话1:

SET DEBUG_SYNC= ‘RESET‘;
SET DEBUG_SYNC= ‘before_lock_tables_takes_lock SIGNAL opened WAIT_FOR flushed‘;
mysql> insert into t2 select 1;     卡住

窗口2,GDB 调试mysqld进程 ,查看用户线程状态

GDB:

Thread 2 (Thread 0x7f7c2f1fe940 (LWP 16108)):
#0  0x00007f7c989cd280 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x0000000000abe163 in safe_cond_timedwait (cond=0x17ecd70 <debug_sync_global+48>, mp=0x17ecda8 <debug_sync_global+104>, abstime=0x7f7c2f1fbc00, file=0xee85d8 "/usr/src/mysql-5.6.28/include/mysql/psi/mysql_thread.h", line=1199) at /usr/src/mysql-5.6.28/mysys/thr_mutex.c:278
#2  0x0000000000613ada in inline_mysql_cond_timedwait (that=0x17ecd70 <debug_sync_global+48>, mutex=0x17ecda8 <debug_sync_global+104>, abstime=0x7f7c2f1fbc00, src_file=0xee81c8 "/usr/src/mysql-5.6.28/sql/debug_sync.cc", src_line=1863) at /usr/src/mysql-5.6.28/include/mysql/psi/mysql_thread.h:1199
#3  0x00000000006141aa in debug_sync_execute (thd=0x48f3f20, action=0x4a9d780) at /usr/src/mysql-5.6.28/sql/debug_sync.cc:1861
#4  0x00000000006147ce in debug_sync (thd=0x48f3f20, sync_point_name=0xf12440 "before_lock_tables_takes_lock", name_len=29) at /usr/src/mysql-5.6.28/sql/debug_sync.cc:1973
#5  0x00000000007604bd in lock_tables (thd=0x48f3f20, tables=0x4a948e0, count=0, flags=0) at /usr/src/mysql-5.6.28/sql/sql_base.cc:6046
#6  0x00000000008082be in mysql_select (thd=0x48f3f20, tables=0x4a948e0, wild_num=0, fields=..., conds=0x0, order=0x48f6680, group=0x48f65b8, having=0x0, select_options=2684619520, result=0x4a955c8, unit=0x48f5e70, select_lex=0x48f64b8) at /usr/src/mysql-5.6.28/sql/sql_select.cc:1202
#7  0x000000000080854d in handle_select (thd=0x48f3f20, result=0x4a955c8, setup_tables_done_option=0) at /usr/src/mysql-5.6.28/sql/sql_select.cc:110
#8  0x00000000007cdc4e in execute_sqlcom_select (thd=0x48f3f20, all_tables=0x4a948e0) at /usr/src/mysql-5.6.28/sql/sql_parse.cc:5134
#9  0x00000000007cf185 in mysql_execute_command (thd=0x48f3f20) at /usr/src/mysql-5.6.28/sql/sql_parse.cc:2656
#10 0x00000000007d67c4 in mysql_parse (thd=0x48f3f20, rawbuf=0x4a946c0 "show databases", length=14, parser_state=0x7f7c2f1fd910) at /usr/src/mysql-5.6.28/sql/sql_parse.cc:6386
#11 0x00000000007d83f4 in dispatch_command (command=COM_QUERY, thd=0x48f3f20, packet=0x4a8c251 "show databases", packet_length=14) at /usr/src/mysql-5.6.28/sql/sql_parse.cc:1340
#12 0x00000000007d9c80 in do_command (thd=0x48f3f20) at /usr/src/mysql-5.6.28/sql/sql_parse.cc:1037
#13 0x000000000078e3fb in do_handle_one_connection (thd_arg=0x48f3f20) at /usr/src/mysql-5.6.28/sql/sql_connect.cc:982
#14 0x000000000078e4c1 in handle_one_connection (arg=0x48f3f20) at /usr/src/mysql-5.6.28/sql/sql_connect.cc:898
#15 0x0000000000b11172 in pfs_spawn_thread (arg=0x479cd00) at /usr/src/mysql-5.6.28/storage/perfschema/pfs.cc:1860
#16 0x00007f7c989c883d in start_thread () from /lib64/libpthread.so.0
#17 0x00007f7c97e75fdd in clone () from /lib64/libc.so.6
#18 0x0000000000000000 in ?? ()

sql_base.cc:6046
DEBUG_SYNC(thd, "before_lock_tables_takes_lock");

    if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
                                        flags)))
      DBUG_RETURN(TRUE);

DEBUG_SYNC(thd, "after_lock_tables_takes_lock");

sql_base.cc:1351
void close_thread_tables(THD *thd)
{
  TABLE *table;
  DBUG_ENTER("close_thread_tables");

#ifdef EXTRA_DEBUG
  DBUG_PRINT("tcache", ("open tables:"));
  for (table= thd->open_tables; table; table= table->next)
    DBUG_PRINT("tcache", ("table: ‘%s‘.‘%s‘ 0x%lx", table->s->db.str,
                          table->s->table_name.str, (long) table));
#endif

#if defined(ENABLED_DEBUG_SYNC)
  /* debug_sync may not be initialized for some slave threads */
  if (thd->debug_sync_control)
    DEBUG_SYNC(thd, "before_close_thread_tables");
#endif

  DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt ||
              (thd->state_flags & Open_tables_state::BACKUPS_AVAIL));

  /* Detach MERGE children after every statement. Even under LOCK TABLES. */
  for (table= thd->open_tables; table; table= table->next)
  {
    /* Table might be in use by some outer statement. */
    DBUG_PRINT("tcache", ("table: ‘%s‘  query_id: %lu",
                          table->s->table_name.str, (ulong) table->query_id));
    if (thd->locked_tables_mode <= LTM_LOCK_TABLES ||
        table->query_id == thd->query_id)
    {
      DBUG_ASSERT(table->file);
      table->file->extra(HA_EXTRA_DETACH_CHILDREN);
    }
  }

会话3:

mysql> SET DEBUG_SYNC= ‘now WAIT_FOR opened‘;
Query OK, 0 rows affected (0.00 sec)

mysql> SET DEBUG_SYNC= ‘after_flush_unlock SIGNAL flushed‘;
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH TABLE t1;
Query OK, 0 rows affected (0.20 sec)

会话1:

mysql> insert into t2 select 1;
Query OK, 1 row affected (1 min 25.42 sec)
Records: 1  Duplicates: 0  Warnings: 0
时间: 2025-01-03 20:33:27

mysqld --debug-sync的相关文章

mysqld --debug=d:t:i:O:n --user=mysql (源码调试)

--debug=d:t--debug=d:f,main,subr1:F:L:t,20--debug=d,input,output,files:n--debug=d:t:i:O,\\mysqld.trace--debug=d:t:i:O --debug=d:t --debug=d:f,main,subr1:F:L:t,20 --debug=d,input,output,files:n --debug=d:t:i:O,\\mysqld.trace --debug=d:t:i:O ./mysqld 

mysqld 多线程 用pstree -p 显示

http://blog.chinaunix.net/uid-22566367-id-3751084.html http://blog.csdn.net/fly2nn/article/details/6980236 pstree -p 6762    :mysqld 多线程序,当一个请求来,就建立一个线程 (12244 ,15470) 为MYSQL登陆对应的服务线程,其他线程不变 进程的pid: [[email protected] ~]# ps -ef | grep mysqld | grep

Chapter 5 MySQL Server Administration_1

Chapter 5 MySQL Server Administration Table of Contents 5.1 The MySQL Server 5.1.1 Configuring the Server 5.1.2 Server Configuration Defaults 5.1.3 Server Option and Variable Reference 5.1.4 Server Command Options 5.1.5 Server System Variables 5.1.6

CentOS 7 源码安装MySQL 5.6.31

本文部分内容参考我之前在CentOS 6下安装MySQL 5.6 的步骤.http://professor.blog.51cto.com/996189/1695769 系统平台:CentOS 7.2 MySQL版本:mysql-5.6.31 安装方式:源码编译 导航1. 下载源码包 2. 解压源码包.安装依赖包 3. 编译安装mysql 4. 安装后配置,包括CentOS 7服务配置 5. my.cnf配置举例 6. mysqld.service配置举例 1. 下载源码包 wget http:/

mysql数据库的编译安装

mysql5.1之前编译mysql使用的是make工具,编译步骤如下: ./configure --prefix= make &&make install mysql5.5之后编译mysql使用的是cmake工具,编译步骤如下: cmake . 查看帮助使用: cmake -LH 或ccmake . 1.创建mysql用户及安装依赖软件包. [[email protected] mnt]# groupadd -r mysql [[email protected] mnt]# useradd

zabbix监控mysql(perl)

1. yum install perl-libwww-perl yum install perl-File-Which yum install perl-DBD-MySQL yum install perl-Digest-SHA1 yum install perl-Time-HiRes yum install perl-Crypt-SSLeay 2.测试 #!/usr/bin/perl -w use DBI; my $database = "mysql"; my $hostname =

Golang中使用heap编写一个简单高效的定时器模块

定时器模块在服务端开发中非常重要,一个高性能的定时器模块能够大幅度提升引擎的运行效率.使用Golang和heap实现一个通用的定时器模块,代码来自:https://github.com/xiaonanln/goTimer 也可以查看文档:http://godoc.org/github.com/xiaonanln/goTimer,下面是完整的代码,并进行适当的注释和分析. 从性能测试结果来看,基于heap的定时器模块在效率上并不会比时间轮(TimeWheel)的实现慢多少,但是逻辑上要简单很多.

mysql 源码调试方法

http://blog.itpub.net/29254281/viewspace-1847415/ 其中吕海波老师分享的内容是 <调试Oracle二三例:调试技术在日常运维中的应用>其中有关于调试MySQL源码的内容. 实验如下:下载MySQL 5.7的源码http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.9.tar.gz 编译,注意增加 DEBUG 选项.(cmake的版本要求在2.8.2以上)cmake \-DCMAKE_INSTALL

MySQL解释--百度百科

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一. MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性. MySQL所使用的 SQL 语言是用于访问数据

MySQL5.5 安装mcafee mysql-audit插件 不成功

主页:https://github.com/mcafee/mysql-audit/wiki 各版本安装包:https://bintray.com/mcafee/mysql-audit-plugin/release 安装步骤还是比较简单的,只有几步: 1)查看插件目录 mysql> SHOW GLOBAL VARIABLES LIKE 'plugin_dir'; +---------------+--------------------+ | Variable_name | Value | +--