• Marko Mäkelä's avatar
    MDEV-32050: Do not copy undo records in purge · aa719b50
    Marko Mäkelä authored
    Also, default to innodb_purge_batch_size=1000,
    replacing the old default value of processing 300 undo log pages
    in a batch. Axel Schwenke found this value to help reduce purge lag
    without having a significant impact on workload throughput.
    
    In purge, we can simply acquire a shared latch on the undo log page
    (to avoid a race condition like the one that was fixed in
    commit b102872a) and retain a buffer-fix
    after releasing the latch. The buffer-fix will prevent the undo log
    page from being evicted from the buffer pool. Concurrent modification
    is prevented by design. Only the purge_coordinator_task
    (or its accomplice purge_truncation_task) may free the undo log pages,
    after any purge_worker_task have completed execution. Hence, we do not
    have to worry about any overwriting or reuse of the undo log records.
    
    trx_undo_rec_copy(): Remove. The only remaining caller would have been
    trx_undo_get_undo_rec_low(), which is where the logic was merged.
    
    purge_sys_t::m_initialized: Replaces heap.
    
    purge_sys_t::pages: A cache of buffer-fixed pages that have been
    looked up from buf_pool.page_hash.
    
    purge_sys_t::get_page(): Return a buffer-fixed undo page, using the
    pages cache.
    
    trx_purge_t::batch_cleanup(): Renamed from clone_end_view().
    Clear the pages cache and clone the end_view at the end of a batch.
    
    purge_sys_t::n_pages_handled(): Return pages.size(). This determines
    if innodb_purge_batch_size was exceeded.
    
    purge_sys_t::rseg_get_next_history_log(): Replaces
    trx_purge_rseg_get_next_history_log().
    
    purge_sys_t::choose_next_log(): Replaces trx_purge_choose_next_log()
    and trx_purge_read_undo_rec().
    
    purge_sys_t::get_next_rec(): Replaces trx_purge_get_next_rec()
    and trx_undo_get_next_rec().
    
    purge_sys_t::fetch_next_rec(): Replaces trx_purge_fetch_next_rec()
    and some use of trx_undo_get_first_rec().
    
    trx_purge_attach_undo_recs(): Do not allow purge_sys.n_pages_handled()
    exceed the innodb_purge_batch_size or ¾ of the buffer pool, whichever
    is smaller.
    
    Reviewed by: Vladislav Lesin
    Tested by: Matthias Leich and Axel Schwenke
    aa719b50
trx0undo.h 19.2 KB