转载: https://www.cnblogs.com/DataArt/p/10260994.html

【问题】

最近查看MySQL的error log文件时,发现有很多服务器的文件中有大量的如下日志,内容很长(大小在200K左右),从记录的内容看,并没有明显的异常信息。

有一台测试服务器也有类似的问题,为什么会记录这些信息,是谁记录的这些信息,分析的过程比较周折。

Status information:

Current dir:

Running threads: 2452  Stack size: 262144

Current locks:

lock: 0x7f783f5233f0:

Key caches:

default

Buffer_size:       8388608

Block_size:           1024

Division_limit:        100

Age_limit:             300

blocks used:            10

not flushed:             0

w_requests:           6619

writes:                  1

r_requests:         275574

reads:                1235

handler status:

read_key:   32241480828

read_next:  451035381896

read_rnd     149361175

read_first:    1090473

write:      4838429521

delete        12155820

update:     3331297842

【分析过程】 

1、首先在官方文档中查到,当mysqld进程收到SIGHUP信号量时,就会输出类似的信息,

On Unix, signals can be sent to processes. mysqld responds to signals sent to it as follows:

SIGHUP causes the server to reload the grant tables and to flush tables, logs, the thread cache, and the host cache. These actions are like various forms of the FLUSH statement. The server also writes a status report to the error log that has this format:

https://dev.mysql.com/doc/refman/5.6/en/server-signal-response.html

 

2、有别的程序在kill mysqld进程吗,用systemtap脚本监控kill命令

probe nd_syscall.kill

{

target[tid()] = uint_arg(1);

signal[tid()] = uint_arg(2);

}

probe nd_syscall.kill.return

{

if (target[tid()] != 0) {

printf("%-6d %-12s %-5d %-6d %6d\n", pid(), execname(),

signal[tid()], target[tid()], int_arg(1));

delete target[tid()];

delete signal[tid()];

}

}

用下面命令测试,确实会在error log中记录日志

kill -SIGHUP 12455

从systemtap的输出看到12455就是mysqld进程,被kill掉了,信号量是1,对应的就是SIGHUP

不过在测试环境后面问题重现时,却没有抓到SIGHUP的信号量。

FROM   COMMAND      SIG   TO     RESULT

17010  who          0     12153  1340429600

36681  bash         1     12455     642

3、看来并不是kill导致的,后面用gdb attach到mysqld进程上,在error log的三个入口函数sql_print_error,sql_print_warning,sql_print_information加上断点

但是在问题重现时,程序并没有停在断点处

4、写error log还有别的分支吗,翻源码找到了答案,原来是通过mysql_print_status函数直接写到error log中

void mysql_print_status()

{

char current_dir[FN_REFLEN];

STATUS_VAR current_global_status_var;

printf("\nStatus information:\n\n");

(void) my_getwd(current_dir, sizeof(current_dir),MYF(0));

printf("Current dir: %s\n", current_dir);

printf("Running threads: %u  Stack size: %ld\n",

Global_THD_manager::get_instance()->get_thd_count(),

(long) my_thread_stack_size);

puts("");

fflush(stdout);

}

 

5、再次用gdb attach到mysqld进程上,在mysql_print_status函数上加断点,在问题重现时,线程停在断点处,通过ps的结果多次对比,判断是pt-stalk工具运行时调用了mysql_print_status

6、从堆栈中看到dispatch_command调用了mysql_print_status,下面是具体的逻辑,当command=COM_DEBUG时就会执行到mysql_print_status

case COM_DEBUG:

thd->status_var.com_other++;

if (check_global_access(thd, SUPER_ACL))

break;                /* purecov: inspected */

mysql_print_status();

query_logger.general_log_print(thd, command, NullS);

my_eof(thd);

break;

7、查看pt-stalk的代码

if [ "$mysql_error_log" -a ! "$OPT_MYSQL_ONLY" ]; then

log "The MySQL error log seems to be $mysql_error_log"

tail -f "$mysql_error_log" >"$d/$p-log_error" &

tail_error_log_pid=$!

      $CMD_MYSQLADMIN $EXT_ARGV debug

else

log "Could not find the MySQL error log"

 

在调用mysqladmin时使用了debug模式

debug         Instruct server to write debug information to log

 

8、在percona官网上搜到了相关的bug描述,目前bug还未修复,会在下个版本中3.0.13中修复。

https://jira.percona.com/browse/PT-1340

【解决方案】

定位到问题后,实际修复也比较简单,将pt-stalk脚本中$CMD_MYSQLADMIN $EXT_ARGV debug中的debug去掉就可以了,测试生效。

总结:

(1)  通过mysql_print_status函数直接写到error log中

(2)  执行mysqladmin debug

(3) 资源紧张,kill session等 (同时参考:  https://dev.mysql.com/doc/refman/5.7/en/server-signal-response.html)

Status information:

Current dir: /data/mysql/mysql3306/data/
Running threads: 7 Stack size: 262144
Current locks:
lock: 0x7fdcb0a44780:

lock: 0x7fdcaf0ea980:

lock: 0x1edb5a0:

..........

..........

Key caches:
default
Buffer_size: 8388608
Block_size: 1024
Division_limit: 100
Age_limit: 300
blocks used: 9
not flushed: 0
w_requests: 0
writes: 0
r_requests: 82
reads: 13

handler status:
read_key: 16981474
read_next: 33963080
read_rnd 6
read_first: 192
write: 21270
delete 0
update: 16981221

Table status:
Opened tables: 956
Open tables: 206
Open files: 13
Open streams: 0

Memory status:
<malloc version="1">
<heap nr="0">
<sizes>
<unsorted from="140586808432240" to="140585778669336" total="0" count="140585778669312"/>
</sizes>
<total type="fast" count="0" size="0"/>
<total type="rest" count="0" size="0"/>
<system type="current" size="0"/>
<system type="max" size="0"/>
<aspace type="total" size="0"/>
<aspace type="mprotect" size="0"/>
</heap>
<total type="fast" count="0" size="0"/>
<total type="rest" count="0" size="0"/>
<total type="mmap" count="0" size="0"/>
<system type="current" size="0"/>
<system type="max" size="0"/>
<aspace type="total" size="0"/>
<aspace type="mprotect" size="0"/>
</malloc>

Events status:
LLA = Last Locked At LUA = Last Unlocked At
WOC = Waiting On Condition DL = Data Locked

Event scheduler status:
State : INITIALIZED
Thread id : 0
LLA : n/a:0
LUA : n/a:0
WOC : NO
Workers : 0
Executed : 0
Data locked: NO

Event queue status:
Element count : 0
Data locked : NO
Attempting lock : NO
LLA : init_queue:96
LUA : init_queue:104
WOC : NO
Next activation : never

转载于:https://www.cnblogs.com/lirulei90/p/10435982.html

【转载】谁记录了mysql error log中的超长信息相关推荐

  1. 谁记录了mysql error log中的超长信息

    [问题] 最近查看MySQL的error log文件时,发现有很多服务器的文件中有大量的如下日志,内容很长(大小在200K左右),从记录的内容看,并没有明显的异常信息. 有一台测试服务器也有类似的问题 ...

  2. mysql 超长记录_谁记录了mysql error log中的超长信息(记pt-stalk一个bug的定位过程)...

    [问题] 最近查看MySQL的error log文件时,发现有很多服务器的文件中有大量的如下日志,内容很长(大小在200K左右),从记录的内容看,并没有明显的异常信息. 有一台测试服务器也有类似的问题 ...

  3. mysql error.log 权限_docker-compose 启动mysql 容器时 error.log 无权限访问怎么办?

    场景分析 docker-compose 运行mysql 容器的时候一直报下面的错误: .../var/log/mysql/mysql-error.log' for error logging: Per ...

  4. mysql error log清理_手动删除mysql日志/var/log/mysql/error.log导致的mysql无法启动

    问题环境 ubuntu-mate for raspberry mysql默认配置 问题起源 最近在搞fail2ban这东西,顺便翻了翻各种日志,然后看见mysql的日志有点多就想清理一下,于是直接su ...

  5. nginx error.log中的 favicon.ico 错误

    今天配置一个测试域名,然后重启nginx,发现error log中很多如下错误: 2014/06/27 10:35:47 [error] 23757#0: *196360 open() "/ ...

  6. Python统计网站访问日志log中的IP信息,并排序。。

    Python统计网站访问日志log中的IP信息,并排序,打印排名靠前的IP及访问量.示例代码如下: #!/usr/bin/env pythonipdict = {}file = open(" ...

  7. mysql 5.7 mts_mysql5.7 中启用MTS后error log中大量Note日志分析

    mysql5.7,启用基于logical_clock的多线程复制,发现error日志增长很快,查看日志发现大量关于多线程复制的Note级别日志.1 2 3 4 5 6 7 8 9 10 11 12 1 ...

  8. 【报错记录】MySQL向数据库中导入txt文件报错ERROR 1148 (42000): The used command is not allowed with this MySQL version

    背景 想将txt文件导入到数据库中,输入LOAD DATA LOCAL INFILE "D:\dbms_lab\department.txt" INTO TABLE DEPARTM ...

  9. mysql查询一个数据库所有表的记录数,mysql 查看数据库中所有表的记录数

    mysql使用select count(*) from table_name可以查询某个表的总记录数.想快速的知道数据库中所有表的记录数信息怎么办?如果使用mysql的版本在5.0及以上,可以通过查询 ...

最新文章

  1. jsp 分页 tag
  2. 【HDU - 1134 】Game of Connections(JAVA大数加法,卡特兰数)
  3. html-网页基本标签
  4. Lecture 6:值函数近似
  5. Java并发编程实战 -- 读书笔记
  6. 传智播客 java javaEE 20G全套视频教程(下载种子)
  7. mapgis转arcgis
  8. ArcCatalog不能预览地图服务
  9. ckplayer.js视频播放插件
  10. WinCap数据包显示
  11. webjs - 财联社登录密码加密入口及JS改写
  12. 【文献管理】Zotero基础操作
  13. python古诗代码案例_一行代码竟然如此逆天?小码王python案例首次对外展现!
  14. UE4-(雾效)大气雾
  15. 【学习笔记】[省选联考 2023] 填数游戏
  16. 危险的外围设备:Windows和Linux系统的计算机内部安全隐患研究
  17. P1423 小玉在游泳 NOIP python题解
  18. 干货分享 | Swift在淘系技术的演进历程
  19. 2225年,人类可以通过脑机永生?
  20. 讲真话、求真知、做真我——Facebook COO桑德伯格2012哈佛商学院毕业演讲

热门文章

  1. java实现条件编译
  2. Kafka剖析(一):Kafka背景及架构介绍
  3. 【Machine Learning实验1】batch gradient descent(批量梯度下降) 和 stochastic gradient descent(随机梯度下降)
  4. java学习笔记15--多线程编程基础2
  5. 微分求积:复化梯形、复化辛浦生
  6. VS2010+OpenCV2.4.3配置(一次设置,永久生效)
  7. GraphQL 学习
  8. Ubuntu16.10安装Ocata之4:Neutron
  9. 数据库事务系列-事务模型基础
  10. js 中的break continue return