天天看点

mysql5.7 事务提交innodb记录binlog的文件名及偏移

#0  trx_sys_update_mysql_binlog_offset (file_name=0x2d23222 <mysql_bin_log+130> "mysql-bin.000026", offset=226, field=15384, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0sys.cc:225
#1  0x0000000001af4989 in trx_write_serialisation_history (trx=0x7fffd78cfd20, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0trx.cc:1699
#2  0x0000000001af5bbb in trx_commit_low (trx=0x7fffd78cfd20, mtr=0x7fff92fa7a80) at storage/innobase/trx/trx0trx.cc:2143
#3  0x0000000001af5d2f in trx_commit (trx=0x7fffd78cfd20) at storage/innobase/trx/trx0trx.cc:2213
#4  0x0000000001af6436 in trx_commit_for_mysql (trx=0x7fffd78cfd20) at storage/innobase/trx/trx0trx.cc:2432
#5  0x00000000018cc992 in innobase_commit_low (trx=0x7fffd78cfd20) at storage/innobase/handler/ha_innodb.cc:4296
#6  0x00000000018cce81 in innobase_commit (hton=0x2dd1be0, thd=0x7fff54000b70, commit_trx=true) at storage/innobase/handler/ha_innodb.cc:4458
#7  0x0000000000f42bad in ha_commit_low (thd=0x7fff54000b70, all=true, run_after_commit=false) at sql/handler.cc:1914
#8  0x00000000017f0f33 in MYSQL_BIN_LOG::process_commit_stage_queue (this=0x2d231a0 <mysql_bin_log>, thd=0x7fff54000b70, first=0x7fff54000b70) at sql/binlog.cc:9111
#9  0x00000000017f2b29 in MYSQL_BIN_LOG::ordered_commit (this=0x2d231a0 <mysql_bin_log>, thd=0x7fff54000b70, all=true, skip_commit=false) at sql/binlog.cc:9892
#10 0x00000000017f0800 in MYSQL_BIN_LOG::commit (this=0x2d231a0 <mysql_bin_log>, thd=0x7fff54000b70, all=true) at sql/binlog.cc:8908
#11 0x0000000000f42889 in ha_commit_trans (thd=0x7fff54000b70, all=true, ignore_global_read_lock=false) at sql/handler.cc:1810
#12 0x00000000016432ce in trans_commit (thd=0x7fff54000b70) at sql/transaction.cc:246
#13 0x000000000154bb16 in mysql_execute_command (thd=0x7fff54000b70, first_level=true) at sql/sql_parse.cc:4254
#14 0x000000000154f2f6 in mysql_parse (thd=0x7fff54000b70, parser_state=0x7fff92faa540) at sql/sql_parse.cc:5584
#15 0x00000000015448ee in dispatch_command (thd=0x7fff54000b70, com_data=0x7fff92faacd0, command=COM_QUERY) at sql/sql_parse.cc:1491
#16 0x000000000154373f in do_command (thd=0x7fff54000b70) at sql/sql_parse.cc:1032
#17 0x0000000001674b25 in handle_connection (arg=0x696de50) at sql/conn_handler/connection_handler_per_thread.cc:313
#18 0x0000000001d12388 in pfs_spawn_thread (arg=0x692a5b0) at storage/perfschema/pfs.cc:2197
#19 0x00007ffff7bc6e65 in start_thread () from /lib64/libpthread.so.0


209| /*****************************************************************//**
 210| Updates the offset information about the end of the MySQL binlog entry
 211| which corresponds to the transaction just being committed. In a MySQL
 212| replication slave updates the latest master binlog position up to which
 213| replication has proceeded. */
 214| void
 215| trx_sys_update_mysql_binlog_offset(
 216| /*===============================*/
 217|         const char*     file_name,/*!< in: MySQL log file name */
 218|         int64_t         offset, /*!< in: position in that log file */
 219|         ulint           field,  /*!< in: offset of the MySQL log info field in
 220|                                 the trx sys header */
 221|         mtr_t*          mtr)    /*!< in: mtr */
 222| {
 223|         trx_sysf_t*     sys_header;
 224|
 225+>        if (ut_strlen(file_name) >= TRX_SYS_MYSQL_LOG_NAME_LEN) {
 226|
 227|                 /* We cannot fit the name to the 512 bytes we have reserved */
 228|
 229|                 return;
 230|         }
 231|
 232|         sys_header = trx_sysf_get(mtr);
 233|
 234|         if (mach_read_from_4(sys_header + field
 235|                              + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD)
 236|             != TRX_SYS_MYSQL_LOG_MAGIC_N) {
 237|
 238|                 mlog_write_ulint(sys_header + field
 239|                                  + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD,
 240|                                  TRX_SYS_MYSQL_LOG_MAGIC_N,
 241|                                  MLOG_4BYTES, mtr);
 242|         }
 243|
 244|         if (0 != strcmp((char*) (sys_header + field + TRX_SYS_MYSQL_LOG_NAME),
 245|                         file_name)) {
 246|
 247|                 mlog_write_string(sys_header + field
 248|                                   + TRX_SYS_MYSQL_LOG_NAME,
 249|                                   (byte*) file_name, 1 + ut_strlen(file_name),
 250|                                   mtr);
 251|         }
 252|
 253|         if (mach_read_from_4(sys_header + field
 254|                              + TRX_SYS_MYSQL_LOG_OFFSET_HIGH) > 0
 255|             || (offset >> 32) > 0) {
 256|
 257|                 mlog_write_ulint(sys_header + field
 258|                                  + TRX_SYS_MYSQL_LOG_OFFSET_HIGH,
 259|                                  (ulint)(offset >> 32),
 260|                                  MLOG_4BYTES, mtr);
 261|         }
 262|
 263|         mlog_write_ulint(sys_header + field
 264|                          + TRX_SYS_MYSQL_LOG_OFFSET_LOW,
 265|                          (ulint)(offset & 0xFFFFFFFFUL),
 266|                          MLOG_4BYTES, mtr);
 267| }