Innodb: 自动开启打印show engine status到err日志

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 这个问题是一个朋友问我的@刘加奇一、问题描述为什么我的err日志里面有大量的show engine innodb status的记录,我自己并没有开启innodb_status_output参数。

这个问题是一个朋友问我的@刘加奇

一、问题描述

为什么我的err日志里面有大量的show engine innodb status的记录,我自己并没有开启innodb_status_output参数。

二、问题分析

通过查看日志,发现如下输出:

2019-03-21T17:00:02.375231Z 1230497 [Warning] InnoDB: Difficult to find free blocks in the buffer pool (338 
search iterations)! 0 failed attempts to flush a page! Consider increasing the buffer pool size. It is also possible 
that in your Unix version fsync is very slow, or completely frozen inside the OS kernel. Then upgrading to a 
newer version of your operating system may help. Look at the number of fsyncs in diagnostic info below. 
Pending flushes (fsync) log: 0; buffer pool: 0. 1446962050 OS file reads, 545881917 OS file writes, 
376257282 OS fsyncs. Starting InnoDB Monitor to print further diagnostics to the standard output.

日志也写得很清楚。应该是free block不够了Innodb自动开启了。但是我们需要源码验证一下。

三、源码验证

在源码的buf_LRU_handle_lack_of_free_blocks函数中我们看到如下:

if ((current_ms > started_ms + 2000)
        && (current_ms > last_printout_ms + 2000)
        && srv_buf_pool_old_size == srv_buf_pool_size) {

        ib::warn() << "Difficult to find free blocks in the buffer pool"
            " (" << n_iterations << " search iterations)! "
               << flush_failures << " failed attempts to"
            " flush a page! Consider increasing the buffer pool"
            " size. It is also possible that in your Unix version"
            " fsync is very slow, or completely frozen inside"
            " the OS kernel. Then upgrading to a newer version"
            " of your operating system may help. Look at the"
            " number of fsyncs in diagnostic info below."
            " Pending flushes (fsync) log: "
               << fil_n_pending_log_flushes
               << "; buffer pool: "
               << fil_n_pending_tablespace_flushes
               << ". " << os_n_file_reads << " OS file reads, "
               << os_n_file_writes << " OS file writes, "
               << os_n_fsyncs
               << " OS fsyncs. Starting InnoDB Monitor to print"
            " further diagnostics to the standard output.";

        last_printout_ms = current_ms;
        *mon_value_was = srv_print_innodb_monitor;
        *started_monitor = true;
        srv_print_innodb_monitor = true;
        os_event_set(srv_monitor_event);

这里不仅打印出了日志同时设置了参数srv_print_innodb_monitor = true; 并且开始os_event_set(srv_monitor_event);开启了monitor打印线程。那我们看看srv_print_innodb_monitor 对应什么参数呢。如下:

static MYSQL_SYSVAR_BOOL(status_output, srv_print_innodb_monitor,
  PLUGIN_VAR_OPCMDARG, "Enable InnoDB monitor output to the error log.",
  NULL, innodb_status_output_update, FALSE);

实际上就是innodb_status_output被自动开了。当然如果查看调用可以在上层函数buf_LRU_get_free_block中查看到调用,实际上就是在free list找不到空闲的block的时候会做输出。buf_LRU_get_free_block还包含了一个块的分配流程大约如下,可自行参考:

  • If there is a block in the free list, take it .如果这里找不到就会自动开启innodb_status_output
  • If no block was in the free list, search from the end of the LRU list and try to free a block there.
  • No free block was found: try to flush the LRU list.

作者微信:gp_22389860

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
3月前
|
缓存 关系型数据库 MySQL
MySQL数据库——InnoDB引擎-架构-内存结构(Buffer Pool、Change Buffer、Adaptive Hash Index、Log Buffer)
MySQL数据库——InnoDB引擎-架构-内存结构(Buffer Pool、Change Buffer、Adaptive Hash Index、Log Buffer)
87 3
|
4月前
|
存储 SQL 关系型数据库
详解InnoDB(2)——日志
详解InnoDB(2)——日志
87 1
|
4月前
|
存储 SQL 关系型数据库
MySQL之深入InnoDB存储引擎——redo日志
我们知道数据的修改首先是在Buffer Pool中进行的,之后再定时刷到磁盘中。那么如果在事务提交后还没刷新到磁盘中,系统就崩溃了,那么此时数据就丢失了,这就不满足事务的持久性了。而如果我们考虑每次提交之后,都同步将事务中所有的页面刷新到磁盘,这样确实可以保证持久性,但是这种方法存在以下两种问题:
|
11月前
|
关系型数据库 MySQL 数据库
阿里云Mysql数据库物理全备文件恢复到自建数据库Mysql报错:InnoDB: Log file ./...xtrabacku
阿里云Mysql数据库物理全备文件恢复到自建数据库Mysql报错:InnoDB: Log file ./...xtrabacku
|
SQL 缓存 运维
InnoDB重做日志架构和innodb_redo_log_capacity系统变量(译文)
说明:从MySQL 8.0.30开始,InnoDB的重做日志架构发生了重大变化,重做日志文件被固定为32个,并存放在一个专门的目录下面,用户可以使用系统变量innodb_redo_log_capacity在线修改重做日志容量,原来的innodb_log_files_in_group和innodb_log_file_size两个系统变量已经废弃。
232 0
|
关系型数据库 MySQL 容器
MySQL 8 新参数innodb_dedicated_server的作用,多了64个日志文件ib_logfile
MySQL 8 中可以设置参数 innodb_dedicated_server=ON来让MySQL自动探测服务器的内存大小,根据内存大小设置innodb_buffer_pool_size, innodb_log_file_size 和 innodb_flush_method 三个参数。
217 0
|
SQL NoSQL 安全
Percona 8.0.30中"show engine innodb status"导致coredump排查及分析
Percona 8.0.30中"show engine innodb status"导致coredump排查及分析
|
SQL 存储 监控
【MySQL从入门到精通】【高级篇】(二十二)慢查询日志分析,SHOW PROFILE查看SQL执行成本
上一篇文章我们介绍数据库的优化步骤【MySQL从入门到精通】【高级篇】(二十一)数据库优化步骤_查看系统性能参数,其中,说到了通过开启慢查询日志来分析慢查询的SQL。这篇文章就是具体来介绍如何开启慢查询日志以及如何分析慢查询日志。
410 0
【MySQL从入门到精通】【高级篇】(二十二)慢查询日志分析,SHOW PROFILE查看SQL执行成本
|
SQL 存储 关系型数据库
Mysql中 慢查询日志和show profile进行sql分析
MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响应时间超过阀值的语句,具体指运行时间超过long_query_time值的SQL,则会被记录到慢查询日志中。
385 0
Mysql中 慢查询日志和show profile进行sql分析
|
SQL 关系型数据库 MySQL
MySQL中ENGINE=InnoDB、AUTO_INCREMENT的意思
MySQL中ENGINE=InnoDB、AUTO_INCREMENT的意思