InnoDB---UNDO日志与回滚

来源:互联网 发布:长春干部网络学校 编辑:程序博客网 时间:2024/06/18 14:30

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

/** Rollback segments assigned to a transaction forundo logging. */

struct trx_rsegs_t{

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

        system/undotablespace used for undo logging of tables that needs to be recovered oncrash. */

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

 

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

        temptablespace used for undo logging of tables that doesn't need to berecovered on crash. */

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

};

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

/** Represents an instance of rollback segmentalong 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; /** pagesize of the relevant tablespace */

    ulint          max_size; /** maximum allowed size inpages */   

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

...

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

    /** Listof update undo logs */

    UT_LIST_BASE_NODE_T(trx_undo_t)    update_undo_list;

    /** Listof update undo log segments cached for fast reuse */

   UT_LIST_BASE_NODE_T(trx_undo_t)   update_undo_cached;

 

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

    /** Listof insert undo logs */

   UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list;

    /** Listof insert undo log segments cached for fast reuse */

   UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached;

...

};

0 0