log_warnings

在介绍这个参数前,我们先聊聊参数 log_warnings。我们知道 MySQL 中,其中 log_error 定义是否启用错误日志的功能和错误日志的存储位置,log_warnings 定义是否将告警信息(warning messages)也写入错误日志。此选项默认启用,具体来说:

log_warnings 为 0, 表示不记录告警信息。

log_warnings 为 1, 表示告警信息写入错误日志。

log_warnings 大于 1, 表示各类告警信息,例如有关网络故障的信息和重新连接信息写入错误日志。

注意,此参数在不同版本略有差别,在 MySQL 5.6 中,log_warnings 的默认值为 1,如下所示:

Property

Value

Command-Line Format

--log-warnings[=#]

System Variable

log_warnings

Scope(>= 5.6.4)

Global

Scope(<= 5.6.3)

Global, Session

Dynamic

Yes

Type(64-bit platforms)

integer

Type(32-bit platforms)

integer

Default Value(64-bit platforms)

1

Default Value(32-bit platforms)

1

Minimum Value(64-bit platforms)

0

Minimum Value(32-bit platforms)

0

Maximum Value(64-bit platforms)

18446744073709551615

Maximum Value(32-bit platforms)

4294967295

在 MySQL 5.7 中,有些版本默认值为 2,有些版本默认值为 1, 具体参考官方文档信息,如下所示:

Property

Value

Command-Line Format

--log-warnings[=#]

Deprecated

5.7.2

System Variable

log_warnings

Scope

Global

Dynamic

Yes

Type (64-bit platforms)

integer

Type (32-bit platforms)

integer

Default Value (64-bit platforms, >= 5.7.2)

2

Default Value (64-bit platforms, <= 5.7.1)

1

Default Value (32-bit platforms, >= 5.7.2)

2

Default Value (32-bit platforms, <= 5.7.1)

1

Minimum Value (64-bit platforms)

0

Minimum Value (32-bit platforms)

0

Maximum Value (64-bit platforms)

18446744073709551615

Maximum Value (32-bit platforms)

4294967295

将告警信息,例如连接中断等告警信息输出到错误日志。该选项默认启用(默认值为1)。要禁用它,请使用--log-warnings = 0选项。指定没有级别值的选项时,将当前值递增1。推荐将这个值设置为大于0启用告警日志信息写入错误日志。举个例子,如果你正在使用复制(你将会获取正在发生的事情的更多详细信息,例如有关网络故障的信息和重新连接信息)。如果该值大于1,连接中断将写入错误日志,新的连接尝试访问的拒绝访问信息。参见Section B.5.2.11, “Communication Errors and Aborted。

如果从服务器(slave server)启动时启用了--log-warnings,则从设备将消息输出到错误日志中以提供有关其状态的信息,例如二进制日志和中继日志坐标,它在开始作业时切换到另一个中继日志,断开连接后重新连接等等。如果--log-warnings大于0,服务器将记录关于对基于语句的日志不安全的语句的消息。

注意,从 MySQL 5.7.2 开始,首选 log_error_verbosity 系统变量,而不是使用--log-warnings选项或log_warnings系统变量,这个参数从 MySQL 8.0.3 开始被移除了。

Note

This system variable was removed in MySQL 8.0.3. Use the log_error_verbosity system variable instead.

log_error_verbosity

新参数 log_error_verbosity 更简单,它有三个可选值, 分别对应:1 错误信息;2  错误信息和告警信息;3:错误信息、告警信息和通知信息。 具体参考官方文档,下面部分截取官方文档。

Property

Value

Command-Line Format

--log-error-verbosity=#

System Variable

log_error_verbosity

Scope

Global

Dynamic

Yes

SET_VAR Hint Applies

No

Type

integer

Default Value(>= 8.0.4)

2

Default Value(<= 8.0.3)

3

Minimum Value

1

Maximum Value

3

用于处理错误日志的事件的详细程度,由错误日志过滤器组件 log_filter_internal 进行过滤。如果未启用 log_filter_internal,则 log_error_verbosity 不起作用。下表显示了允许的详细度值。

Desired Log Filtering

log_error_verbosity Value

Error messages

1

Error and warning messages

2

Error, warning, and note messages

3

从上面表格可以看出,从 MySQL 5.7->MySQL 8.0.3 此参数的默认值为 3,大于 MySQL 8.0.3 开始默认值调整为 2 了。所以,在 MySQL 5.7 版本中,你可能在错误日志信息中看到一大堆Note类型的日志。具体参考这篇文章“MySQL 5.7错误日志中常见的几种Note级别日志解释”。

log_error_verbosity 与 innodb_print_all_deadlocks

在 MySQL 中,发生死锁的时候,我们可以选择把死锁日志输出到 error log 中,通过开启 innodb_print_all_deadlocks 参数控制。这里有一个小问题,开启 innodb_print_all_deadlocks 后,输出到 error log 中的日志级别为 Note。也就是说,当 log_error_verbosity=3 的时候,Note 级别日志才会输出到 error log 中。具体日志信息格式如下:

2020-11-20T02:55:59.599990Z 1693135 [Note] InnoDB: Transactions deadlock detected, dumping detailed information.

2020-11-20T02:55:59.600008Z 1693135 [Note] InnoDB:

*** (1) TRANSACTION:

TRANSACTION 24688, ACTIVE 16 sec starting index read

mysql tables in use 1, locked 1

LOCK WAIT 3 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1

MySQL thread id 1693133, OS thread handle 139675801577216, query id 153219328 localhost root updating

update t1 set name='c' where id=2

2020-11-20T02:55:59.600038Z 1693135 [Note] InnoDB: *** (1) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 103 page no 3 n bits 80 index PRIMARY of table `sbtest`.`t1` trx id 24688 lock_mode X locks rec but not gap waiting

Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0

0: len 4; hex 80000002; asc ;;

1: len 6; hex 000000006071; asc `q;;

2: len 7; hex 560000014c09b8; asc V L ;;

3: len 1; hex 63; asc c;;

4: len 1; hex 62; asc b;;

2020-11-20T02:55:59.600173Z 1693135 [Note] InnoDB: *** (2) TRANSACTION:

TRANSACTION 24689, ACTIVE 6 sec starting index read

mysql tables in use 1, locked 1

3 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1

MySQL thread id 1693135, OS thread handle 139675802642176, query id 153219329 localhost root updating

update t1 set name='c' where id=1

2020-11-20T02:55:59.600195Z 1693135 [Note] InnoDB: *** (2) HOLDS THE LOCK(S):

RECORD LOCKS space id 103 page no 3 n bits 80 index PRIMARY of table `sbtest`.`t1` trx id 24689 lock_mode X locks rec but not gap

Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0

0: len 4; hex 80000002; asc ;;

1: len 6; hex 000000006071; asc `q;;

2: len 7; hex 560000014c09b8; asc V L ;;

3: len 1; hex 63; asc c;;

4: len 1; hex 62; asc b;;

2020-11-20T02:55:59.600302Z 1693135 [Note] InnoDB: *** (2) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 103 page no 3 n bits 80 index PRIMARY of table `sbtest`.`t1` trx id 24689 lock_mode X locks rec but not gap waiting

Record lock, heap no 8 PHYSICAL RECORD: n_fields 5; compact format; info bits 0

0: len 4; hex 80000001; asc ;;

1: len 6; hex 000000006070; asc `p;;

2: len 7; hex 550000019504ff; asc U ;;

3: len 1; hex 63; asc c;;

4: len 1; hex 61; asc a;;

2020-11-20T02:55:59.600410Z 1693135 [Note] InnoDB: *** WE ROLL BACK TRANSACTION (2)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

2020-11-20T02:55:59.599990Z1693135[Note]InnoDB:Transactionsdeadlockdetected,dumpingdetailedinformation.

2020-11-20T02:55:59.600008Z1693135[Note]InnoDB:

***(1)TRANSACTION:

TRANSACTION24688,ACTIVE16secstartingindexread

mysqltablesinuse1,locked1

LOCKWAIT3lockstruct(s),heapsize1136,2rowlock(s),undologentries1

MySQLthreadid1693133,OSthreadhandle139675801577216,queryid153219328localhostrootupdating

updatet1setname='c'whereid=2

2020-11-20T02:55:59.600038Z1693135[Note]InnoDB:***(1)WAITINGFORTHISLOCKTOBEGRANTED:

RECORDLOCKSspaceid103pageno3nbits80indexPRIMARYoftable`sbtest`.`t1`trxid24688lock_modeXlocksrecbutnotgapwaiting

Recordlock,heapno3PHYSICALRECORD:n_fields5;compactformat;infobits0

0:len4;hex80000002;asc;;

1:len6;hex000000006071;asc`q;;

2:len7;hex560000014c09b8;ascVL;;

3:len1;hex63;ascc;;

4:len1;hex62;ascb;;

2020-11-20T02:55:59.600173Z1693135[Note]InnoDB:***(2)TRANSACTION:

TRANSACTION24689,ACTIVE6secstartingindexread

mysqltablesinuse1,locked1

3lockstruct(s),heapsize1136,2rowlock(s),undologentries1

MySQLthreadid1693135,OSthreadhandle139675802642176,queryid153219329localhostrootupdating

updatet1setname='c'whereid=1

2020-11-20T02:55:59.600195Z1693135[Note]InnoDB:***(2)HOLDSTHELOCK(S):

RECORDLOCKSspaceid103pageno3nbits80indexPRIMARYoftable`sbtest`.`t1`trxid24689lock_modeXlocksrecbutnotgap

Recordlock,heapno3PHYSICALRECORD:n_fields5;compactformat;infobits0

0:len4;hex80000002;asc;;

1:len6;hex000000006071;asc`q;;

2:len7;hex560000014c09b8;ascVL;;

3:len1;hex63;ascc;;

4:len1;hex62;ascb;;

2020-11-20T02:55:59.600302Z1693135[Note]InnoDB:***(2)WAITINGFORTHISLOCKTOBEGRANTED:

RECORDLOCKSspaceid103pageno3nbits80indexPRIMARYoftable`sbtest`.`t1`trxid24689lock_modeXlocksrecbutnotgapwaiting

Recordlock,heapno8PHYSICALRECORD:n_fields5;compactformat;infobits0

0:len4;hex80000001;asc;;

1:len6;hex000000006070;asc`p;;

2:len7;hex550000019504ff;ascU;;

3:len1;hex63;ascc;;

4:len1;hex61;asca;;

2020-11-20T02:55:59.600410Z1693135[Note]InnoDB:***WEROLLBACKTRANSACTION(2)

是不是意味着 log_error_verbosity<3 时,就算 innodb_print_all_deadlocks=ON,死锁日志也不会记录到 error log 中呢?

其实两者还是有点差别,当 log_error_verbosity<3 & innodb_print_all_deadlocks=ON 时,还是会记录死锁日志到 error log 中,不过日志简化了一些,格式如下:

TRANSACTION 24700, ACTIVE 12 sec starting index read

mysql tables in use 1, locked 1

LOCK WAIT 3 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1

MySQL thread id 1693181, OS thread handle 139675801310976, query id 153223910 localhost root updating

update t1 set name='c' where id=2

RECORD LOCKS space id 103 page no 3 n bits 80 index PRIMARY of table `sbtest`.`t1` trx id 24700 lock_mode X locks rec but not gap waiting

Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0

0: len 4; hex 80000002; asc ;;

1: len 6; hex 00000000607d; asc `};;

2: len 7; hex 5c000005640f57; asc \ d W;;

3: len 1; hex 63; asc c;;

4: len 1; hex 62; asc b;;

TRANSACTION 24701, ACTIVE 5 sec starting index read

mysql tables in use 1, locked 1

3 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1

MySQL thread id 1693182, OS thread handle 139675801843456, query id 153223911 localhost root updating

update t1 set name='c' where id=1

RECORD LOCKS space id 103 page no 3 n bits 80 index PRIMARY of table `sbtest`.`t1` trx id 24701 lock_mode X locks rec but not gap

Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0

0: len 4; hex 80000002; asc ;;

1: len 6; hex 00000000607d; asc `};;

2: len 7; hex 5c000005640f57; asc \ d W;;

3: len 1; hex 63; asc c;;

4: len 1; hex 62; asc b;;

RECORD LOCKS space id 103 page no 3 n bits 80 index PRIMARY of table `sbtest`.`t1` trx id 24701 lock_mode X locks rec but not gap waiting

Record lock, heap no 8 PHYSICAL RECORD: n_fields 5; compact format; info bits 0

0: len 4; hex 80000001; asc ;;

1: len 6; hex 00000000607c; asc `|;;

2: len 7; hex 5b00000562080c; asc [ b ;;

3: len 1; hex 63; asc c;;

4: len 1; hex 61; asc a;;

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

TRANSACTION24700,ACTIVE12secstartingindexread

mysqltablesinuse1,locked1

LOCKWAIT3lockstruct(s),heapsize1136,2rowlock(s),undologentries1

MySQLthreadid1693181,OSthreadhandle139675801310976,queryid153223910localhostrootupdating

updatet1setname='c'whereid=2

RECORDLOCKSspaceid103pageno3nbits80indexPRIMARYoftable`sbtest`.`t1`trxid24700lock_modeXlocksrecbutnotgapwaiting

Recordlock,heapno3PHYSICALRECORD:n_fields5;compactformat;infobits0

0:len4;hex80000002;asc;;

1:len6;hex00000000607d;asc`};;

2:len7;hex5c000005640f57;asc\dW;;

3:len1;hex63;ascc;;

4:len1;hex62;ascb;;

TRANSACTION24701,ACTIVE5secstartingindexread

mysqltablesinuse1,locked1

3lockstruct(s),heapsize1136,2rowlock(s),undologentries1

MySQLthreadid1693182,OSthreadhandle139675801843456,queryid153223911localhostrootupdating

updatet1setname='c'whereid=1

RECORDLOCKSspaceid103pageno3nbits80indexPRIMARYoftable`sbtest`.`t1`trxid24701lock_modeXlocksrecbutnotgap

Recordlock,heapno3PHYSICALRECORD:n_fields5;compactformat;infobits0

0:len4;hex80000002;asc;;

1:len6;hex00000000607d;asc`};;

2:len7;hex5c000005640f57;asc\dW;;

3:len1;hex63;ascc;;

4:len1;hex62;ascb;;

RECORDLOCKSspaceid103pageno3nbits80indexPRIMARYoftable`sbtest`.`t1`trxid24701lock_modeXlocksrecbutnotgapwaiting

Recordlock,heapno8PHYSICALRECORD:n_fields5;compactformat;infobits0

0:len4;hex80000001;asc;;

1:len6;hex00000000607c;asc`|;;

2:len7;hex5b00000562080c;asc[b;;

3:len1;hex63;ascc;;

4:len1;hex61;asca;;

可以看到具体的 Note 日志条目确实没有记录了,只有一些具体的死锁信息,友好度差了一些。

结论,两个参数并没有必然关系,开启了 innodb_print_all_deadlocks 参数必然会记录死锁日志,具体的死锁日志额外的 Note 信息靠 log_error_verbosity 参数来控制。

如果您觉得本站对你有帮助,那么可以支付宝扫码捐助以帮助本站更好地发展,在此谢过。

mysql报警级别_MySQL 5.7定义日志级别新参数(log_error_verbosity)相关推荐

  1. MySQL新参数log_error_verbosity

    在介绍这个参数前,我们先聊聊参数log_warnings.我们知道MySQL中,其中log_error定义是否启用错误日志的功能和错误日志的存储位置,log_warnings定义是否将告警信息(war ...

  2. mysql spring隔离级别_MySQL事务与Spring隔离级别实现

    1.事务具有ACID特性 原子性(atomicity):一个事务被事务不可分割的最小工作单元,要么全部提交,要么全部失败回滚. 一致性(consistency):数据库总是从一致性状态到另一个一致性状 ...

  3. 以mysql为例有几种隔离级别_mysql有几种隔离级别

    mysql有4种隔离级别,分别为:1.读未提交内容:2.读取提交内容:3.可重复读:4.可串行化. Mysql的四种隔离级别 SQL标准定义了4类隔离级别,包括了一些具体规则,用来限定事务内外的哪些改 ...

  4. mysql数据 锁 隔离级别_MySQL数据库事务各隔离级别加锁情况--read uncommitted篇

    1.目的 1.1 合适人群 1.数据库事务特征我只是背过,并没有很深刻的理解. 2.数据库事务的隔离级别只是了解,并没有深刻理解,也没有在实际工作中体验使用过. 3.经常面试被人问起数据库加锁情况,一 ...

  5. glog 设置日志级别_如何动态改变日志级别

    前言 关于日志级别,大部分项目可能都设置为info级别,当然也可能有一些追求性能或者说包含很多敏感信息的项目直接将级别设置为warn或者error:这时候如果项目中出现一些未知异常,需要用到很详细的日 ...

  6. java logger 日志级别_Java如何设置Logger日志级别?

    在此示例中,您将看到我们如何更改或设置Logger日志级别.日志级别将告诉您Logger将记录哪个特定的日志消息. Logger如果级别等于或高于级别,则仅记录日志消息Logger.例如,当级别设置L ...

  7. mysql 慢查询_mysql如何捕捉慢日志查询

    慢日志查询日志 查询超过变量 long_query_time指定时间值的为慢查询,但是查询获取锁(包括锁等待)的时间不计入查询时间内,mysql 记录慢查询日志是在查询执行完毕且已经完全释放锁之后才记 ...

  8. mysql当时读_Mysql事务以及四中隔离级别实例2以及InnoDB如何解决当时读的幻读问题...

    接着上一篇笔记:http://blog.csdn.net/qq_33366229/article/details/78337354 第三级别(重复读): 第二种情况: 也就是基于上一种情况 事务A在事 ...

  9. mysql 消极锁_MySQL支持的事物隔离级别以及消极锁和乐观锁原理和应用场景

    在一样平常开发中,尤其是营业开发,少不了行使 Java 对数据库举行基本的增删改查等数据操作,这也是Java工程师的必备手艺之一.做好数据操作,不仅仅需要对Java语言相关框架的掌握,更需要对种种数据 ...

最新文章

  1. BTN8982基本测试
  2. 增强我们的Visual Studio(更新中)
  3. 已解决:大家使用原子哥的延时函数delay_ms,delay_us会出现进入延时函数出不来的情况
  4. 在Apache上搭建pywebsocket提供html5的websocket服务
  5. java 拦截器响应中取所有参数,spring boot拦截器中获取request post请求中的参数
  6. UVALive - 7511 Multiplication Table(暴力+模拟)
  7. zxing android最新下载,Zxing简单集成
  8. fork join框架_Fork / Join框架vs.并行流vs.ExecutorService:最终的Fork / Join基准
  9. 每天一个实用小技巧!归纳多个文件、批量修改文件名
  10. “摔杯一怒为俞渝” 当当创始人李国庆:蓄谋已久的阴谋 不吐不快
  11. anaconda环境中使用sudo python报错
  12. win7服务器未能登入,Win7提示profile服务未能登录,无法在系统中创建怎么办
  13. 虚拟机是ubuntu,windows映射盘符方式访问虚拟机
  14. 职场感悟.Video.人生各自精彩,谁说人生是一场马拉松的?
  15. 用js处理图片加载错误时加载默认图片的方法
  16. 【MM模块】Credit Memos and Reversals 红字发票和冲销
  17. MongoDB $lookup函数实现两个表的关联查询+筛选+取特定值
  18. Latex公式字母加粗
  19. Java面试题(六)腾讯Spring夺命7连问(灵魂拷问)
  20. 关于String str1 = “123“ 和 String str2 = new String(“123“)内存分析

热门文章

  1. python奇淫巧技
  2. lasergrbl调整XYZA各轴电机运动方向
  3. static final
  4. iOS设备的UDID是什么?苹果为什么拒绝获取iOS设备UDID的应用?如何替代UDID?
  5. VScode主题色更换
  6. 超宽带的应用、 开发及发展前景
  7. haar级联分类器车辆检测_Haar级联分类器Open CV用于人脸检测的术语
  8. Navicat12 Linux安装
  9. IPv4私有IP地址有哪些!
  10. wkhtmltox实现网页转换成图片或pdf