在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

MySQL DDL锁表情况分析

132次阅读
没有评论

共计 2963 个字符,预计需要花费 8 分钟才能阅读完成。

这篇文章主要介绍“MySQL DDL 锁表情况分析”,在日常操作中,相信很多人在 MySQL DDL 锁表情况分析问题上存在疑惑,丸趣 TV 小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MySQL DDL 锁表情况分析”的疑惑有所帮助!接下来,请跟着丸趣 TV 小编一起来学习吧!

版本 5.7.22,隔离级别 RR

当 DDL 的表存在慢查询时,此时对该表做 DDL,由于无法获得 metadata 锁,所以会等待该锁,造成锁表,后续 DML 操作全部进入等待状态。
session1:

session2:

session3:

session4:

tips:
select sleep(N) from t; 表示查询 t 的时间为 t 中的行数 *N,如下:

Before an online DDL operation can finish, it must wait for transactions that hold metadata locks on the table to commit or roll back. An online DDL operation may briefly require an exclusive metadata lock on the table during its execution phase, and always requires one in the final phase of the operation when updating the table definition. Consequently, transactions holding metadata locks on the table can cause an online DDL operation to block. The transactions that hold metadata locks on the table may have been started before or during the online DDL operation. A long running or inactive transaction that holds a metadata lock on the table can cause an online DDL operation to timeout.
在线 DDL 操作完成之前,必须等待持有表上的元数据锁的事务提交或回滚。在线 DDL 操作在执行阶段可能会短暂地需要表上的独占元数据锁,并且在更新表定义时总是在操作的最后阶段需要一个锁。因此,持有表上的元数据锁的事务可能导致在线 DDL 操作阻塞。表上持有元数据锁的事务可能在 DDL 在线操作之前或期间启动。在表上持有元数据锁的长时间运行或不活动的事务可能导致在线 DDL 操作超时。
https://dev.mysql.com/doc/refman/5.6/en/innodb-online-ddl-limitations.html
Online DDL and Metadata Locks
Online DDL operations can be viewed as having three phases:    DDL 的在线操作可以分为三个阶段:

Phase 1: Initialization   初始化
In the initialization phase, the server determines how much concurrency is permitted during the operation, taking into account storage engine capabilities, operations specified in the statement, and user-specified ALGORITHM and LOCK options. During this phase, a shared upgradeable metadata lock is taken to protect the current table definition.
在初始化阶段,服务器考虑存储引擎功能、语句中指定的操作以及用户指定的算法和锁选项,确定操作期间允许多少并发性。在此阶段,使用共享的可升级元数据锁来保护当前表定义。

Phase 2: Execution
In this phase, the statement is prepared and executed. Whether the metadata lock is upgraded to exclusive depends on the factors assessed in the initialization phase. If an exclusive metadata lock is required, it is only taken briefly during statement preparation.
在这个阶段,语句被准备好并执行。元数据锁是否升级为 exclusive 取决于初始化阶段评估的因素。如果需要独占元数据锁,则只在语句准备期间进行短暂的锁定。

Phase 3: Commit Table Definition 提交表定义
In the commit table definition phase, the metadata lock is upgraded to exclusive to evict the old table definition and commit the new one. Once granted, the duration of the exclusive metadata lock is brief.
在提交表定义阶段,将元数据锁升级为 exclusive,以删除旧表定义并提交新表定义。一旦获得授权,独占元数据锁的持续时间很短。
Due to the exclusive metadata lock requirements outlined above, an online DDL operation may have to wait for concurrent transactions that hold metadata locks on the table to commit or rollback. Transactions started before or during the DDL operation can hold metadata locks on the table being altered. In the case of a long running or inactive transaction, an online DDL operation can time out waiting for an exclusive metadata lock. Additionally, a pending exclusive metadata lock requested by an online DDL operation blocks subsequent transactions on the table.
由于上面列出的独占元数据锁需求,在线 DDL 操作可能必须等待持有表上的元数据锁的并发事务提交或回滚。DDL 操作之前或期间启动的事务可以在被修改的表上持有元数据锁。在长时间运行或不活动的事务的情况下,在线 DDL 操作可能会超时,等待独占元数据锁。此外,在线 DDL 操作请求的挂起的独占元数据锁会阻塞表上的后续事务。

到此,关于“MySQL DDL 锁表情况分析”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注丸趣 TV 网站,丸趣 TV 小编会继续努力为大家带来更多实用的文章!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-28发表,共计2963字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 中文字幕在线免费观看 | 久久精品99香蕉国产 | 久久老子午夜精品无码怎么打 | 胯下粗长挺进人妻体内电影 | 亚洲成a人片在线观看天堂无码 | 人妻18毛片a级毛片免费看 | 欧洲精品在线视频 | 日本在线看片网站 | 国产精品制服一区二区 | 青青草国产成人久久91网 | 毛片com| 最近中文字幕无吗免费视频 | 国产综合视频在线观看 | 国产精品免费久久久久影院 | 一区二区三区视频观看 | 久久中文字幕在线 | 9久爱午夜视频 | 国产9 9在线 | 欧洲 | 国产精品无码不卡一区二区三区 | 无码国产色欲xxxxx视频 | 亚洲欧洲无码一区二区三区 | 欧美乱妇高清无乱码 | 国内精品国产三级国产av | 久久久久久美女精品啪啪 | 国产1区| 男人的天堂免费网站 | 免费中文字幕不卡视频 | 成人免费视频一区二区三区 | 久操香蕉 | 精品亚洲成a人在线播放 | 久久亚洲一区二区 | 美女狂揉尿口揉到失禁 | 亚洲无av在线中文字幕 | 3a毛片| 久久伊人电影 | 久久国产欧美日韩精品免费 | 久久在精品线影院精品国产 | 欧美国产一区二区二区 | 天天综合色天天综合色sb | 继攵女乱h调教手册苏柔 | 两个人看的免费视频 |