InnoDB---UNDO日志与回滚

    事务通过trx_rsegs_t与系统表空间和临时表空间等物理存储联系起来的方式如下:

/** Rollback segments assigned to a transaction for undo logging. */

struct trx_rsegs_t {

    /** undo log ptr holding reference to a rollback segment that resides in

        system/undo tablespace used for undo logging of tables that needs to be recovered on crash. */

    trx_undo_ptr_t    m_redo;   //系统的UNDO表空间

 

    /** undo log ptr holding reference to a rollback segment that resides in

        temp tablespace used for undo logging of tables that doesn't need to be recovered on crash. */

    trx_undo_ptr_t    m_noredo; //系统的临时表空间

};

    系统表空间和临时表空间等物理存储与UNDO日志之间的关系如下:

/** Represents an instance of rollback segment along with its state variables.*/

struct trx_undo_ptr_t {  

    //标识分配给事务的回滚段,这样把事务和回滚段建立起联系来。然后通过trx_rsegs_t与系统表空间和临时表空间等物理存储联系起来

    trx_rseg_t*    rseg;          //指向回滚段

    trx_undo_t*    insert_undo;    /*!< pointer to the insert undo log, or NULL if no inserts performed yet */  //事务指向insert undo log

    trx_undo_t*    update_undo;    /*!< pointer to the update undo log, or ULL if no update performed yet */    //事务指向update undo log

};

    而回滚段的信息又如下:

/** The rollback segment memory object */

struct trx_rseg_t {

    ulint    id;      //回滚段的标识

...

    ulint    space;   //回滚段的头信息在表空间中的位置,表空间标识

    ulint    page_no; //回滚段的头信息在表空间中的位置,页号

 

    page_size_t    page_size; /** page size of the relevant tablespace */

    ulint          max_size; /** maximum allowed size in pages */   

    ulint          curr_size; /** current size in pages */

...

    /** 执行UPDATE操作产生的UODO日志,包括先删除后插入的过程中产生的UODO信息,事务完成,信息依然被保留,用于MVCC机制下的一致性读  */

    /** List of update undo logs */

    UT_LIST_BASE_NODE_T(trx_undo_t)    update_undo_list;

    /** List of update undo log segments cached for fast reuse */

    UT_LIST_BASE_NODE_T(trx_undo_t)    update_undo_cached;

 

    /* 执行INSERT操作产生的UODO日志,这些信息是临时的,事务结束后就被清理 */

    /** List of insert undo logs */

    UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list;

    /** List of insert undo log segments cached for fast reuse */

    UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached;

...

};

猜你喜欢

转载自blog.csdn.net/fly2nn/article/details/61924836