0
votes

mysql Default level repeatable read; Why mysql generate read view when select or not update、insert、delete;

mysql> begin; Query OK, 0 rows affected (0.00 sec)

mysql> update z set b =1 where a =1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0


Trx id counter 12688 Purge done for trx's n:o < 12688 undo n:o < 0 state: running but idle History list length 54 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 281479607651904, not started 0 lock struct(s), heap size 1136, 0 row lock(s) ---TRANSACTION 281479607651000, not started 0 lock struct(s), heap size 1136, 0 row lock(s) ---TRANSACTION 281479607650096, not started 0 lock struct(s), heap size 1136, 0 row lock(s)

This time did not create read view...

1
It seems your query is doing an update on z table, but your question isn't clear... - DaFois
there are specific problem in answer... - rud wei

1 Answers

0
votes

I did not say clearly the problem;

Source code:https://github.com/mysql/mysql-server/blob/5.7/storage/innobase/include/read0types.h

this is ReadView;

private:
    // Disable copying
    ReadView(const ReadView&);
    ReadView& operator=(const ReadView&);

private:
    /** The read should not see any transaction with trx id >= this
    value. In other words, this is the "high water mark". */
    trx_id_t    m_low_limit_id;

    /** The read should see all trx ids which are strictly
    smaller (<) than this value.  In other words, this is the
    low water mark". */
    trx_id_t    m_up_limit_id;

    /** trx id of creating transaction, set to TRX_ID_MAX for free
    views. */
    trx_id_t    m_creator_trx_id;

    /** Set of RW transactions that was active when this snapshot
    was taken */
    ids_t       m_ids;

    /** The view does not need to see the undo logs for transactions
    whose transaction number is strictly smaller (<) than this value:
    they can be removed in purge if not needed by other views */
    trx_id_t    m_low_limit_no;

    /** AC-NL-RO transaction view that has been "closed". */
    bool        m_closed;

    typedef UT_LIST_NODE_T(ReadView) node_t;

    /** List of read views in trx_sys */
    byte        pad1[64 - sizeof(node_t)];
    node_t      m_view_list;
};

Why mysql create this read view when select; but not update、insert、delete。