Hashtag: “We are all little frogs” public account article

I explained how InnoDB’s MVCC works in the MySQL transaction Isolation Level and MVCC article a few days ago, but there was an error in one place, I would like to correct it.

What’s wrong with the original:

When a transaction generates a readView, the system will write the current read/write transaction to the m_IDS list. In order to determine the visibility of a record, the previous article stated that the record is not visible if the trx_ID attribute is greater than the maximum value in m_IDS.

Should be corrected to read:

When a transaction generates a readView, the current read/write transaction being executed on the system is written to the m_IDS list and two values are stored:

  • Min_trx_id: This value represents the minimum value in m_IDS when readView is generated.

  • Max_trx_id: This value represents the ID value in the system that should be assigned to the next transaction when the readView is generated.

    Tip: Note that max_trx_id is not the maximum value in M_IDS; transaction ids are incrementally assigned. Let’s say there are three transactions with IDS 1, 2, and 3, and then the record with ID 3 commits. When a new read transaction generates a readView, m_ids will include 1 and 2, min_trx_id will be 1, max_trx_id will be 4.

So the steps to determine visibility are:

  • If the recordedtrx_idThe column is less thanmin_trx_idThe statement must be visible.
  • If the recordedtrx_idThe column is greater than themax_trx_id, which means it must not be visible.
  • If the recordedtrx_idListed in themin_trx_idandmax_trx_idBetween, we have to look at thetrx_idIs here or notm_idsIf yes, it is not visible; otherwise, it is visible.

If this problem has caused much inconvenience to all students, this problem is also found after a careful look at the MVCC code, before the time of many negligence ~

Consider: What would have been the impact of a previous incorrect version? Understand this problem is to understand MVCC ha ~

digression

This article is from the children’s own public account “we are all little frogs”, welcome to subscribe, there are dry technical articles, sometimes lame.