Giter Site home page Giter Site logo

mysql-8.0.12-with-deadlockthread's Introduction

为mysql增加了一个deadlock thread 定期检测死锁,并且关闭同步检测死锁的功能。

设计初衷

mysql的同步检测死锁耗费过多的cpu,极端情况还会引起大量不必要的锁竞争。 如果关闭死锁检测,锁的等待时间过长会使得业务长时间等待,设置等待时间不是一个根本的解决办法。

所以我们引入了一个单独的线程来进行死锁检测。

优势

  1. 耗费更少CPU,减少mutex等资源竞争。死锁本来就是比较罕见的,并不是每次加锁都会死锁,所以很多死锁检测是没有必要的。
  2. 更快检测到死锁。比关闭死锁检测等待锁超时这种策略能更快的检测到死锁。

使用

linux原生的patch。8.0.13的patch,8以上的版本应该都可以用。 完成之后无需任何设置。innodb每隔1000ms检测一次死锁。还有不要设置innodb_deadlock_detect变量。

性能测试

1500个线程同时更新一行,测试本patch、关闭死锁检测、打开死锁检测,测试版本为mysql8.0.13 结果: patch与关闭死锁检测的TPS基本持平(150),比打开死锁检测高一倍(80左右)。必需使用大线程数量才能测出来,不然三者基本持平。

mysql-8.0.12-with-deadlockthread's People

Contributors

longlong524 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.