mysql5.7 将undo log加入到history list上

 /*================ UNDO LOG HISTORY LIST =============================*/
 318|
 319| /********************************************************************//**
 320| Adds the update undo log as the first log in the history list. Removes the
 321| update undo log segment from the rseg slot if it is too big for reuse. */
 322| void
 323| trx_purge_add_update_undo_to_history(
 324| /*=================================*/
 325|         trx_t*          trx,            /*!< in: transaction */
 326|         trx_undo_ptr_t* undo_ptr,       /*!< in/out: update undo log. */
 327|         page_t*         undo_page,      /*!< in: update undo log header page,
 328|                                         x-latched */
 329|         bool            update_rseg_history_len,
 330|                                         /*!< in: if true: update rseg history
 331|                                         len else skip updating it. */
 332|         ulint           n_added_logs,   /*!< in: number of logs added */
 333|         mtr_t*          mtr)            /*!< in: mtr */
 334| {
 335|         trx_undo_t*     undo;
 336|         trx_rseg_t*     rseg;
 337|         trx_rsegf_t*    rseg_header;
 338|         trx_ulogf_t*    undo_header;
 339|
 340|         undo = undo_ptr->update_undo;
 341+>        rseg = undo->rseg;
 342|
 343|         rseg_header = trx_rsegf_get(
 344|                 undo->rseg->space, undo->rseg->page_no, undo->rseg->page_size,
 345|                 mtr);
 346|
 347|         undo_header = undo_page + undo->hdr_offset;
 348|
 349|         if (undo->state != TRX_UNDO_CACHED) {
 350|                 ulint           hist_size;
 351| #ifdef UNIV_DEBUG
 352|                 trx_usegf_t*    seg_header = undo_page + TRX_UNDO_SEG_HDR;
 353| #endif /* UNIV_DEBUG */
 354| 
 355|                 /* The undo log segment will not be reused */
 356| 
 357|                 if (UNIV_UNLIKELY(undo->id >= TRX_RSEG_N_SLOTS)) {
 358|                         ib::fatal() << "undo->id is " << undo->id;
 359|                 }
 360|
 361|                 trx_rsegf_set_nth_undo(rseg_header, undo->id, FIL_NULL, mtr);
 362|
 363|                 MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED);
 364|
 365|                 hist_size = mtr_read_ulint(
 366|                         rseg_header + TRX_RSEG_HISTORY_SIZE, MLOG_4BYTES, mtr);
 367|
 368|                 ut_ad(undo->size == flst_get_len(
 369|                               seg_header + TRX_UNDO_PAGE_LIST));
 370|
 371|                 mlog_write_ulint(
 372|                         rseg_header + TRX_RSEG_HISTORY_SIZE,
 373|                         hist_size + undo->size, MLOG_4BYTES, mtr);
 374|         }
 375|
 376|         ut_ad(!trx_commit_disallowed);
 377|
 378|         /* Add the log as the first in the history list */
 379|         flst_add_first(rseg_header + TRX_RSEG_HISTORY,
 380|                        undo_header + TRX_UNDO_HISTORY_NODE, mtr);
 381|
 382|         if (update_rseg_history_len) {
 383|                 os_atomic_increment_ulint(
 384|                         &trx_sys->rseg_history_len, n_added_logs);
 385|                 if (trx_sys->rseg_history_len
 386|                     > srv_n_purge_threads * srv_purge_batch_size) {
 387|                         srv_wake_purge_thread_if_not_active();
 388|                 }
 389|         }
 390|
 391|         /* Write the trx number to the undo log header */
 392|         mlog_write_ull(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr);
 393|
 394|         /* Write information about delete markings to the undo log header */
 395|
 396|         if (!undo->del_marks) {
 397|                 mlog_write_ulint(undo_header + TRX_UNDO_DEL_MARKS, FALSE,
 398|                                  MLOG_2BYTES, mtr);
 399|         }
 400|
 401|         if (rseg->last_page_no == FIL_NULL) {
 402|                 rseg->last_page_no = undo->hdr_page_no;
 403|                 rseg->last_offset = undo->hdr_offset;
 404|                 rseg->last_trx_no = trx->no;
 405|                 rseg->last_del_marks = undo->del_marks;
 406|         }
 407| }
#0  trx_purge_add_update_undo_to_history (trx=0x7fffd78cf480, undo_ptr=0x7fffd78cf7d0, undo_page=0x7fffa5880000 "\372\342", <incomplete sequence \302>, update_rseg_history_len=true, n_added_logs=1, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0purge.cc:340
#1  0x0000000001b0541c in trx_undo_update_cleanup (trx=0x7fffd78cf480, undo_ptr=0x7fffd78cf7d0, undo_page=0x7fffa5880000 "\372\342", <incomplete sequence \302>, update_rseg_history_len=true, n_added_logs=1, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0undo.cc:1967
#2  0x0000000001af47a8 in trx_write_serialisation_history (trx=0x7fffd78cf480, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0trx.cc:1656
#3  0x0000000001af5bbb in trx_commit_low (trx=0x7fffd78cf480, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0trx.cc:2143
#4  0x0000000001af5d2f in trx_commit (trx=0x7fffd78cf480) at storage/innobase/trx/trx0trx.cc:2213
#5  0x0000000001af6436 in trx_commit_for_mysql (trx=0x7fffd78cf480) at storage/innobase/trx/trx0trx.cc:2432
#6  0x00000000018cc992 in innobase_commit_low (trx=0x7fffd78cf480) at storage/innobase/handler/ha_innodb.cc:4296
#7  0x00000000018cce81 in innobase_commit (hton=0x2dd1be0, thd=0x7fff54000b70, commit_trx=true) at storage/innobase/handler/ha_innodb.cc:4458
#8  0x0000000000f42bad in ha_commit_low (thd=0x7fff54000b70, all=true, run_after_commit=false) at sql/handler.cc:1914
#9  0x00000000017f0f33 in MYSQL_BIN_LOG::process_commit_stage_queue (this=0x2d231a0 <mysql_bin_log>, thd=0x7fff54000b70, first=0x7fff54000b70) at sql/binlog.cc:9111
#10 0x00000000017f2b29 in MYSQL_BIN_LOG::ordered_commit (this=0x2d231a0 <mysql_bin_log>, thd=0x7fff54000b70, all=true, skip_commit=false) at sql/binlog.cc:9892
#11 0x00000000017f0800 in MYSQL_BIN_LOG::commit (this=0x2d231a0 <mysql_bin_log>, thd=0x7fff54000b70, all=true) at sql/binlog.cc:8908
#12 0x0000000000f42889 in ha_commit_trans (thd=0x7fff54000b70, all=true, ignore_global_read_lock=false) at sql/handler.cc:1810
#13 0x00000000016432ce in trans_commit (thd=0x7fff54000b70) at sql/transaction.cc:246
#14 0x000000000154bb16 in mysql_execute_command (thd=0x7fff54000b70, first_level=true) at sql/sql_parse.cc:4254
#15 0x000000000154f2f6 in mysql_parse (thd=0x7fff54000b70, parser_state=0x7fff92faa540) at sql/sql_parse.cc:5584
#16 0x00000000015448ee in dispatch_command (thd=0x7fff54000b70, com_data=0x7fff92faacd0, command=COM_QUERY) at sql/sql_parse.cc:1491
#17 0x000000000154373f in do_command (thd=0x7fff54000b70) at sql/sql_parse.cc:1032
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值