前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >BUG#26502135: MYSQLD SEGFAULTS IN MDL_CONTEXT::TRY_ACQUIRE_LOCK_IMPL

BUG#26502135: MYSQLD SEGFAULTS IN MDL_CONTEXT::TRY_ACQUIRE_LOCK_IMPL

原创
作者头像
云鹏
修改2021-01-15 17:37:41
5410
修改2021-01-15 17:37:41
举报
文章被收录于专栏:MySQL捉虫MySQL捉虫

被坑了一把,mysql 5.7版本引入LF_HASH来用于MDL子系统,在频繁进行申请和释放metadata lock时数据库可能会crash,

函数堆栈最底层为lf_hash_search,该bug在mysql 5.7.22及以上版本修复。

BUG#26502135: MYSQLD SEGFAULTS IN MDL_CONTEXT::TRY_ACQUIRE_LOCK_IMPL

ANALYSIS:

=========

Server sometimes exited when multiple threads tried toacquire and release metadata locks

simultaneously (forexample, necessary to access a table). The same problem could have

occurred when new objects were registered/deregistered in Performance Schema.

The problem was caused by a bug in LF_HASH - our lock free hash implementation which

is used by metadata lockingsubsystem in 5.7 branch. In 5.5 and 5.6 we only use LF_HASH

in Performance Schema Instrumentation implementation. So for these versions, the problem was limited to P_S.

The problem was in my_lfind() function, which searches for the specific hash element by going

through the elements list. During this search it loads information about element checked such

as key pointer and hash value into local variables. Then it confirms that they are not corrupted

by concurrent delete operation (which will set pointer to 0) by checking if element is still in the list.

The latter check did not take into account that compiler (andprocessor) can reorder reads in such

a way that load of key pointer will happen after it, making result of the checkinvalid.

FIX:

====

This patch fixes the problem by ensuring that no such reordering can take place.

This is achieved by usingmy_atomic_loadptr() which contains compiler and processor

memory barriers for the check mentioned above and othersimilar places.

The default (for non-Windows systems) implementation of my_atomic*() relies on old __sync

intrisics and implementsmy_atomic_loadptr() as read-modify operation. To avoid scalability/performance penalty associated with addition ofmy_atomic_loadptr()'s we change the my_atomic*() to

use newer __atomic intrisics when available. This new default implementation doesn't have such a drawback.

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档