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

简介: 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>
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
弹性计算 负载均衡 对象存储
手把手教你白嫖阿里云服务器(免费领服务器)
手把手教你白嫖阿里云服务器(免费领服务器)阿里云免费服务器领取,个人和企业用户均可以申请,个人免费服务器1核2GB 每月750小时,企业u1服务器2核8GB免费使用3个月,阿里云百科分享阿里云免费服务器申请入口、个人和企业免费配置、申请资格条件及云服务器免费使用时长
1791 0
|
算法 5G
【5G NR】手机身份证号IMEI与IMEISV
手机上的“IMEI”是指国际移动设备识别码(IMEI),通常称为手机序列号。它用于识别移动网络中的各个独立手机和其他移动通信设备,相当于手机身份证号,它是全球唯一的。
2604 0
【5G NR】手机身份证号IMEI与IMEISV
|
6月前
|
人工智能 开发工具 C++
Claude Code 在大型代码库里的工程实践
Anthropic 发布Claude Code大型代码库最佳实践:强调“代码库需适配AI”,而非仅依赖模型。核心在于通过CLAUDE.md分层文档、LSP符号导航、hooks自动维护、skills按需加载、MCP接入内部系统等工程化配置,让Claude高效理解复杂项目(含C/C++/Java等)。配置即能力,治理与负责人机制同样关键。
1274 4
Claude Code 在大型代码库里的工程实践
|
2月前
|
人工智能 算法 Unix
傲慢≠谦虚=圣爱·七美德体系结构性缺陷·否决一切的AI算法
BSD Step237提出革命性洞见:七罪非程度之分,而是本体论层级之别——六罪是人性六种本能的极端化(仍在人性框架内),唯傲慢是否定人性本身、跳出框架的“反人性罪”。传统以“谦虚”对治傲慢实为结构性缺陷,因其仍是封闭的中庸姿态;真正解药是超越人性的“接受性”:无条件承认子集≠母集、拥抱B=C变化、破除封闭。
765 10
|
2月前
|
存储 自然语言处理 NoSQL
GraphRAG详解:基于图检索增强生成,打通大模型关联推理,落地复杂知识图谱问答25.6
GraphRAG是融合知识图谱与大模型的进阶RAG技术,通过实体关系抽取构建图谱,结合图结构检索与向量召回,解决传统RAG在多跳推理、因果关联、事实溯源上的短板,提升复杂问题回答的准确性与可解释性。
438 3
|
Ubuntu Linux 虚拟化
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
4091 0
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
|
2月前
|
弹性计算 人工智能 安全
阿里云99元云服务器购买与使用指南:2核2G3M带宽,续费同价,个人和企业新老用户同享
阿里云99元云服务器以经济型e实例(ecs.e-c1m2.large)为载体,配置2核2G、40GB ESSD Entry云盘、3Mbps固定带宽与1个IPv4公网IP,属标准ECS实例,支持VPC、安全组、快照及备案。活动有效期至2029年3月31日,采用"续费同价",活动期内每年可按99元续费一次,续费时不得变更配置。个人实名主体限保1台,企业主体限保1台99元e实例或1台199元u1实例,二者不可同时持有,可搭配域名、SSL、备案及RDS等组合套餐,适合建站、开发测试、小程序后端等轻中度场景。
|
前端开发 JavaScript 测试技术
React 分页组件 Pagination
本文介绍了如何在 React 中从零构建分页组件,涵盖基础概念、常见问题及解决方案。通过示例代码详细讲解了分页按钮的创建、分页按钮过多、初始加载慢、状态管理混乱等常见问题的解决方法,以及如何避免边界条件、性能优化和用户反馈等方面的易错点。旨在帮助开发者更好地理解和掌握 React 分页组件的开发技巧,提升应用的性能和用户体验。
686 3
|
Linux iOS开发 MacOS
Matplotlib 教程 之 Matplotlib 中文显示 2
Matplotlib 中文显示教程:介绍如何在 Matplotlib 中显示中文,包括设置 Matplotlib 字体参数和下载支持中文的字体库。通过设置 `plt.rcParams[&#39;font.family&#39;]` 为系统中的中文字体(如 SimHei、WenQuanYi Micro Hei、Heiti TC),可以实现中文的正确显示。
865 0
|
人工智能 前端开发 程序员
AI程序员全面上线!聊着天,就把项目开发好了
AI程序员全面上线!聊着天,就把项目开发好了
553 1

热门文章

最新文章