-1

I am trying to understand the internals of how MySql (using InnoDB) implements locking and transactions in code. I understand the different types and concepts of locks and transactions, but I really want to deep dive into understanding how MySQL internally implements in code. I tried going through the documentation and MySQL open source code, but could not find a good starting point. Google was no help either. All search results were talking about the different types of locks, but not how they are implemented actually. Any help here?

New contributor
Sarthak Agarwal is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Jeremy Cole has written some good articles on the internals. Some of Percona's articles get into the internals. The locks (Mutexes) are probably implemented in OS-specific ways. MySQL initially handled a dozen different OSs (Atari, Windows, SunOS, etc) -- So, if you want that low a level, it is probably in some module with lots of "ifdefs". – Rick James Jun 27 at 16:44
0

InnoDB uses MVCC as concurrency control mechanism. Yo can get some more details about it here.

Since you mentioned you want to take a look at the code, I'd suggest downloading the current source code and browsing a bit in the InnoDB directory (storage/innobase). Transactions are implemented in the trx and locking in the lock subfolder. The easiest way is probably to use an IDE and do some kind of keyword search or even build MySQL from source code and debug the execution of a query. Therefore you probably need some kind of knowledge about the interface between the MySQL core and the InnoDB storage engine. You can find these details here: https://dev.mysql.com/doc/internals/en/custom-engine.html

| improve this answer | |
New contributor
julid is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Sarthak Agarwal is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.