MySQL setup_instruments中关于部分信息不能修改

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介: MySQL setup_instruments中关于部分信息不能修改

朋友告诉我如下操作不能修改

  1. mysql> update setup_instruments set enabled='no' where name='memory/performance_schema/table_handles';
  2. Query OK, 1 row affected (2.61 sec)
  3. Rows matched: 1 Changed: 1 Warnings: 0

  4. mysql> select * from setup_instruments where name='memory/performance_schema/table_handles';
  5. +-----------------------------------------+---------+-------+
  6. | NAME | ENABLED | TIMED |
  7. +-----------------------------------------+---------+-------+
  8. | memory/performance_schema/table_handles | YES | NO |
  9. +-----------------------------------------+---------+-------+
  10. 1 row in set (0.00 sec)

我测试发现所有memory/performance_schema/* 的值都不能更改,但是其他值可以更改。8.0.17依然如此。

既然不能修改则跟一下update接口,我一共跟踪了:

  • table_setup_instruments::update_row_values:修改接口
  • table_setup_instruments::make_row:update_enabled 变量传入值
  • table_setup_instruments::rnd_next():update_enabled 定义值

几个接口。


一、为什么不能修改

查看table_setup_instruments::update_row_values函数你会发现memory/performance_schema/* 这几行值这里都会进入如下逻辑:

  1. case 1: /* ENABLED */
  2. /* Do not raise error if m_update_enabled is false, silently ignore. */
  3. if (m_row.m_update_enabled) //这里是 false
  4. {
  5. value= (enum_yes_no) get_field_enum(f);
  6. m_row.m_instr_class->m_enabled= (value == ENUM_YES) ? true : false;
  7. }
  8. break;

因为m_row.m_update_enabled==false 因此不能修改。其他的值这里是true。这里我们也会看到实际上值只有两个YES或者是NO,不能是其他值。如果update修改为其他值会直接报错。


二、mupdateenabled来源

也就是table_setup_instruments::rnd_next()函数进行判断如果是VIEW_BUILTIN_MEMORY则会设置update_enabled为false,具体如下:

  1. case pos_setup_instruments::VIEW_BUILTIN_MEMORY:
  2. update_enabled= false;//这里设置了false
  3. update_timed= false;
  4. ...

当然何为VIEW_BUILTIN_MEMORY,不太清楚,没仔细看了。

最后本表访问是全表扫描方式。因为上层接口为handler::ha_rnd_next,其含义为如下:

  1. The number of requests to read the next row in the data file. This value is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.
  2. 源码函数解释:Reads the next row in a table scan (also used to read the FIRST row in a table scan).
  3. 全表扫描访问下一条数据

debug会发现不断的会访问下一条数据。最后performance_schema是一个独立的引擎,虽然很简单。


三、备用栈帧

1、修改数据

  1. #0 PFS_engine_table::update_row (this=0x7ffe7c1026c0, table=0x7ffe7c1b0370, old_buf=0x7ffe7c1b13f8 "'", new_buf=0x7ffe7c1b1270 "'", fields=0x7ffe7c1b1580)
  2. at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/pfs_engine_table.cc:573
  3. #1 0x0000000001942680 in ha_perfschema::update_row (this=0x7ffe7c1b0d70, old_data=0x7ffe7c1b13f8 "'", new_data=0x7ffe7c1b1270 "'")
  4. at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/ha_perfschema.cc:293
  5. #2 0x0000000000f90b70 in handler::ha_update_row (this=0x7ffe7c1b0d70, old_data=0x7ffe7c1b13f8 "'", new_data=0x7ffe7c1b1270 "'")
  6. at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:8509
  7. #3 0x000000000168ca00 in mysql_update (thd=0x7ffe7c012940, fields=..., values=..., limit=18446744073709551615, handle_duplicates=DUP_ERROR,
  8. found_return=0x7fffec0f4bd8, updated_return=0x7fffec0f4bd0) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_update.cc:887
  9. #4 0x0000000001692f28 in Sql_cmd_update::try_single_table_update (this=0x7ffe7c008f78, thd=0x7ffe7c012940, switch_to_multitable=0x7fffec0f4c7f)
  10. at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_update.cc:2896
  11. #5 0x0000000001693475 in Sql_cmd_update::execute (this=0x7ffe7c008f78, thd=0x7ffe7c012940) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_update.cc:3023
  12. #6 0x00000000015cc8e9 in mysql_execute_command (thd=0x7ffe7c012940, first_level=true) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
  13. #7 0x00000000015d30c6 in mysql_parse (thd=0x7ffe7c012940, parser_state=0x7fffec0f6600) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
  14. #8 0x00000000015c6c5a in dispatch_command (thd=0x7ffe7c012940, com_data=0x7fffec0f6d70, command=COM_QUERY)
  15. at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490

2、读取数据

  1. #0 table_setup_instruments::make_row (this=0x7ffe7c1026c0, klass=0x2f2e3c0, update_enabled=true, update_timed=true)
  2. at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/table_setup_instruments.cc:260
  3. #1 0x00000000019a4b1f in table_setup_instruments::rnd_next (this=0x7ffe7c1026c0)
  4. at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/table_setup_instruments.cc:172
  5. #2 0x0000000001942ab2 in ha_perfschema::rnd_next (this=0x7ffe7c1b0d70, buf=0x7ffe7c1b1270 "")
  6. at /root/mysqlall/percona-server-locks-detail-5.7.22/storage/perfschema/ha_perfschema.cc:351
  7. #3 0x0000000000f83812 in handler::ha_rnd_next (this=0x7ffe7c1b0d70, buf=0x7ffe7c1b1270 "") at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/handler.cc:3146
  8. #4 0x00000000014e2b3d in rr_sequential (info=0x7fffec0f4870) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/records.cc:521
  9. #5 0x000000000168c7b3 in mysql_update (thd=0x7ffe7c012940, fields=..., values=..., limit=18446744073709551615, handle_duplicates=DUP_ERROR,
  10. found_return=0x7fffec0f4bd8, updated_return=0x7fffec0f4bd0) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_update.cc:811
  11. #6 0x0000000001692f28 in Sql_cmd_update::try_single_table_update (this=0x7ffe7c008f78, thd=0x7ffe7c012940, switch_to_multitable=0x7fffec0f4c7f)
  12. at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_update.cc:2896
  13. #7 0x0000000001693475 in Sql_cmd_update::execute (this=0x7ffe7c008f78, thd=0x7ffe7c012940) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_update.cc:3023
  14. #8 0x00000000015cc8e9 in mysql_execute_command (thd=0x7ffe7c012940, first_level=true) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
  15. #9 0x00000000015d30c6 in mysql_parse (thd=0x7ffe7c012940, parser_state=0x7fffec0f6600) at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
  16. #10 0x00000000015c6c5a in dispatch_command (thd=0x7ffe7c012940, com_data=0x7fffec0f6d70, command=COM_QUERY)
  17. at /root/mysqlall/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490



            </div>
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
数据可视化 BI 数据库
Superset执行「superset db upgrade」命令的报错记录
Superset执行「superset db upgrade」命令的报错记录
946 0
Superset执行「superset db upgrade」命令的报错记录
|
数据库 Python
执行superset db upgrade初始化Supetset数据库时报错ImportError: cannot import name ‘soft_unicode’ from ‘markupsaf
执行superset db upgrade初始化Supetset数据库时报错ImportError: cannot import name ‘soft_unicode’ from ‘markupsaf
196 0
|
SQL 关系型数据库 MySQL
MySQL setup_instruments中关于部分信息不能修改
MySQL setup_instruments中关于部分信息不能修改
|
关系型数据库 MySQL SQL
mysql show profile 性能分析工具
mysql show profile 执行时间 消耗时间 时间切片 -DENABLED_PROFILING=bool
mysql show profile 性能分析工具
|
安全 关系型数据库 MySQL
Mysql 安全登陆工具 mysql_config_editor
Mysql 安全登陆工具 mysql_config_editormysql_config_editor帮助信息请查看man mysql_config_editor 或 mysql_config_editor -? 或 mysql_config_editor set -?该工具会在用户家目录生成二进制文件:.mylogin.cnf该文件格式由选项组组成,每个选项组被称为login path ,仅包含特定选项: host, user, password, port and socket 用于用户验证。
1347 0
|
存储 SQL 关系型数据库
MySQL执行外部sql脚本文件命令报错:unknown command '\'
由于编码不一致导致的 虽然大部分导出是没有问题的 但是数据表中存储包含一些脚本(富文本内容)会出现该问题,强制指定编码即可解决。 mysql导入时指定编码: mysql -u root -p --default-character-set=utf8   或者在导出时后显式指定编码就不存在这个问题了:...
1815 0
|
关系型数据库 MySQL 数据库
mysql group by 报错异常解决
mysql报错及其解决方式 1、在使用group by 查询一张表的数据的时候:select date,time,max(delaytime) as delaytime,sum(delaynum) as delaynum, max(onlineCount) as onlineCount,sum(p...
2242 0