mysql transaction MVVC transaction version chain

 

 

 

In the real data in the data page structure, in addition to the real data, there are three hidden columns, one of which is a 6-byte transaction id

 

Read the committed transaction isolation level:

A(300)    =  1

B(200) = 1->2 Transaction B changes the data to 1->2 ->3->4

At this time, it is not submitted. How do you check Fact A again?

When transaction A is read, it will generate a ReadView, which has a m_ids, which transactions are active if it is stored, or which transactions have not yet been committed

Like the example here, it is [81,82,200,300]. With this, it can search down according to this chain and find that 81 is active, then look down again, and find that 80 is not active, and get 80.

If transaction B is committed,

If transaction A is searched again, there is no ReadView m_ids=[81,82,300] of 200, because 200 is submitted, and when it is in the chain search, the chain under 300 is 200, and it is not in the linked list, and 200 is obtained.

 

Repeatable transaction isolation level:

Compared with read submitted, it only generates a ReadView for the first reading, and uses the first ReadView for the second time, so the second check is still the first generated m_ids=[81, 82,200,300], still treating 200 as an active transaction,

Therefore, according to the linked list, the inactive 80 data after 81 is found.

 

 

 

 

 

Guess you like

Origin blog.csdn.net/liuming690452074/article/details/113850598