Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Read-only things in MYSQL innodb and the allocation of id for things

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The level of originality is limited, please point out if there is any mistake.

Read-only things

Maybe someone wants to ask if a select is a thing. In fact, in innodb, the select of an innodb is a thing, it has a trx_t structure, and it is put in the mysql_trx_list linked list, about

Innodb things are done at the system level, but such things are called read-only things

Bool read_only; / *!

< true if transaction is flagged as a READ-ONLY transaction. if auto_commit && will_lock == 0 then it will be handled as a AC-NL-RO-SELECT (Auto Commit Non-Locking Read Only Select). A read only transaction will not be assigned an UNDO log. */ 在实际的使用中他没有自己的锁结构也没有自己的undo segment,这一点很好理解因为这个操作 始终是非锁定的,至少在innodb一级是这样(lock0lock.cc lock_table 都没调用),但是在MYSQL中,我们会发现实际上select语句也会 获得MDL LOCK。(再次声明这里只是说innodb select没有表级别锁存在,但是MYSQL上层会有MDL LOCK) 对于只读事物源码注释给出的流程如下: Auto-commit non-locking read-only: * NOT_STARTED ->

ACTIVE-> NOT_STARTED

Our general 2pc TRX process is as follows:

XA (2PC):

* NOT_STARTED-> ACTIVE-> PREPARED-> COMMITTED-> NOT_STARTED

You can see that he actually does not have the steps of commit, which is certainly not needed without undo reodo. But there is no denying that it is a thing.

In addition, when a thing is needed, it is called in the current innodb version as follows:

Trx_allocate_for_mysql-- > trx_allocate_for_background-- > trx_create_low

This involves the concept of an innodb transaction pool. Trx_create_low fetches a TRX_T structure pointer from the transaction pool to the caller.

After the completion of this step, things are in the NOT_STARTED stage, and at this time, various properties of the TRX_T structure are in the initialization stage, so why should we talk about it?

The concept of thing pool because this concept will be used later when it is said that the item number is assigned.

Then activate things timely according to the needs of the caller. It is actually called, and the call is called through the

Trx_start_if_not_started_low- > trx_start_low is done. Prepare for the structure of things in trx_start_low. Let's take a look.

The next part about the key points in the source code

Optimizing InnoDB Read-Only Transactions, I'm not saying anything anymore.

Author Wechat:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report