mysql 一个事务中形成binlog大于当前线程缓存大小的执行流程

(gdb) where
#0  _my_b_write (info=0x7ffe6c24d910, Buffer=0x7ffe6c0b1a00 "", Count=51358) at /root/mysql-5.7.27_edit_malloc_log/mysys/mf_iocache.c:1313
#1  0x000000000188764c in my_b_safe_write (info=0x7ffe6c24d910, Buffer=0x7ffe6c0b1a00 "", Count=51358) at /root/mysql-5.7.27_edit_malloc_log/mysys/mf_iocache.c:1437
#2  0x00000000017c9f01 in Log_event::wrapper_my_b_safe_write (this=0x7ffe6c26d7a0, file=0x7ffe6c24d910, buf=0x7ffe6c0b1a00 "", size=51358) at /root/mysql-5.7.27_edit_malloc_log/sql/log_event.cc:
1009
#3  0x00000000017e6c45 in Rows_log_event::write_data_body (this=0x7ffe6c26d7a0, file=0x7ffe6c24d910) at /root/mysql-5.7.27_edit_malloc_log/sql/log_event.cc:11647
#4  0x00000000017f15c3 in Log_event::write (this=0x7ffe6c26d7a0, file=0x7ffe6c24d910) at /root/mysql-5.7.27_edit_malloc_log/sql/log_event.h:830
#5  0x00000000018010b8 in binlog_cache_data::write_event (this=0x7ffe6c24d908, thd=0x7ffe6c014fd0, ev=0x7ffe6c26d7a0) at /root/mysql-5.7.27_edit_malloc_log/sql/binlog.cc:1340
#6  0x000000000180efad in MYSQL_BIN_LOG::flush_and_set_pending_rows_event (this=0x2d9af00 <mysql_bin_log>, thd=0x7ffe6c014fd0, event=0x0, is_transactional=true) at /root/mysql-5.7.27_edit_malloc
_log/sql/binlog.cc:7398
#7  0x000000000181914e in THD::binlog_flush_pending_rows_event (this=0x7ffe6c014fd0, stmt_end=true, is_transactional=true) at /root/mysql-5.7.27_edit_malloc_log/sql/binlog.cc:11823
#8  0x00000000018198a1 in THD::binlog_query (this=0x7ffe6c014fd0, qtype=THD::ROW_QUERY_TYPE, query_arg=0x7ffe6c077970 "insert into mytest04(msisdn,fav_brand,fav_big_type,fav_type,flag_code,fav_o
rder,fav_period,free_value,start_time,end_time,group_id,free_value2,product_code,end_time2,marktmp,marktmp2,marktmp3)values(?"..., query_len=302, is_trans=true, direct=false, suppress_use=false,
 errcode=0) at /root/mysql-5.7.27_edit_malloc_log/sql/binlog.cc:12097
#9  0x000000000178a2ef in Sql_cmd_insert::mysql_insert (this=0x7ffe6c094410, thd=0x7ffe6c014fd0, table_list=0x7ffe6c071da8) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_insert.cc:859
#10 0x0000000001790862 in Sql_cmd_insert::execute (this=0x7ffe6c094410, thd=0x7ffe6c014fd0) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_insert.cc:3127
#11 0x000000000156d9db in mysql_execute_command (thd=0x7ffe6c014fd0, first_level=true) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:3596
#12 0x00000000015a9fd4 in Prepared_statement::execute (this=0x7ffe6c00b480, expanded_query=0x7fffec4b7500, open_cursor=false) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_prepare.cc:3977
#13 0x00000000015a8dfb in Prepared_statement::execute_loop (this=0x7ffe6c00b480, expanded_query=0x7fffec4b7500, open_cursor=false, packet=0x7ffe6c27070a "", packet_end=0x7ffe6c27cf6f "") at /roo
t/mysql-5.7.27_edit_malloc_log/sql/sql_prepare.cc:3585
#14 0x00000000015a6784 in mysqld_stmt_execute (thd=0x7ffe6c014fd0, stmt_id=1, flags=0, params=0x7ffe6c27070a "", params_length=51301) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_prepare.cc:257
3
#15 0x00000000015686b6 in dispatch_command (thd=0x7ffe6c014fd0, com_data=0x7fffec4b7e10, command=COM_STMT_EXECUTE) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:1418
#16 0x00000000015678a4 in do_command (thd=0x7ffe6c014fd0) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:1025
#17 0x00000000016976a5 in handle_connection (arg=0xfce9a80) at /root/mysql-5.7.27_edit_malloc_log/sql/conn_handler/connection_handler_per_thread.cc:306
#18 0x0000000001d37250 in pfs_spawn_thread (arg=0xfcc9db0) at /root/mysql-5.7.27_edit_malloc_log/storage/perfschema/pfs.cc:2190
#19 0x00007ffff7bc6e65 in start_thread () from /lib64/libpthread.so.0
#20 0x00007ffff660788d in clone () from /lib64/libc.so.6
(gdb)


/* 
   Write a byte buffer to IO_CACHE and flush to disk
   if IO_CACHE is full.

   RETURN VALUE
    1 On error on write
    0 On success
   -1 On error; my_errno contains error code.
*/

int _my_b_write(IO_CACHE *info, const uchar *Buffer, size_t Count)
{
  size_t rest_length,length;
  my_off_t pos_in_file= info->pos_in_file;

  DBUG_EXECUTE_IF("simulate_huge_load_data_file",
                  {
                    pos_in_file=(my_off_t)(5000000000ULL);
                  });
  if (pos_in_file+info->buffer_length > info->end_of_file)
  {
    errno=EFBIG;
    set_my_errno(EFBIG);
    return info->error = -1;
  }

  rest_length= (size_t) (info->write_end - info->write_pos);
  memcpy(info->write_pos,Buffer,(size_t) rest_length);
  Buffer+=rest_length;
  Count-=rest_length;
  info->write_pos+=rest_length;

  if (my_b_flush_io_cache(info,1))
    return 1;
  if (Count >= IO_SIZE)
  {					/* Fill first intern buffer */
    length=Count & (size_t) ~(IO_SIZE-1);
    if (info->seek_not_done)
    {
      /*
        Whenever a function which operates on IO_CACHE flushes/writes
        some part of the IO_CACHE to disk it will set the property
        "seek_not_done" to indicate this to other functions operating
        on the IO_CACHE.
      */
      if (mysql_file_seek(info->file, info->pos_in_file, MY_SEEK_SET, MYF(0)))
      {
        info->error= -1;
        return (1);
      }
      info->seek_not_done=0;
    }
    if (mysql_file_write(info->file, Buffer, length, info->myflags | MY_NABP))
      return info->error= -1;

    /*
      In case of a shared I/O cache with a writer we normally do direct
      write cache to read cache copy. Simulate this here by direct
      caller buffer to read cache copy. Do it after the write so that
      the cache readers actions on the flushed part can go in parallel
      with the write of the extra stuff. copy_to_read_buffer()
      synchronizes writer and readers so that after this call the
      readers can act on the extra stuff while the writer can go ahead
      and prepare the next output. copy_to_read_buffer() relies on
      info->pos_in_file.
    */
    if (info->share)
      copy_to_read_buffer(info, Buffer, length);

    Count-=length;
    Buffer+=length;
    info->pos_in_file+=length;
  }
  memcpy(info->write_pos,Buffer,(size_t) Count);
  info->write_pos+=Count;
  return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值