美文网首页
MySQL DDL简析(1):inplace DDL 主要st

MySQL DDL简析(1):inplace DDL 主要st

作者: 重庆八怪 | 来源:发表于2021-10-21 15:34 被阅读0次
    
      if (new_stage == &srv_stage_alter_table_read_pk_internal_sort) {
        m_cur_phase = READ_PK;
      } else if (new_stage == &srv_stage_alter_table_merge_sort) {
        m_cur_phase = SORT;
      } else if (new_stage == &srv_stage_alter_table_insert) {
        m_cur_phase = INSERT;
      } else if (new_stage == &srv_stage_alter_table_flush) {
        m_cur_phase = FLUSH;
      } else if (new_stage == &srv_stage_alter_table_log_index) {
        m_cur_phase = LOG_INDEX;
      } else if (new_stage == &srv_stage_alter_table_log_table) {
        m_cur_phase = LOG_TABLE;
      } else if (new_stage == &srv_stage_alter_table_end) {
        m_cur_phase = END;
      } else {
        ut_error;
      }
    
    ha_innobase::inplace_alter_table_impl
     ->row_merge_build_indexes
      ->进入状态
         srv_stage_alter_table_read_pk_internal_sort
      ->row_merge_read_clustered_index
         -> trx->op_info = "reading clustered index"
            事务状态更改为reading clustered index
         -> 获取innodb_tmpdir 参数设置
            thd_innodb_tmpdir
         -> for (ulint i = 0; i < n_index; i++)
            循环每一个索引为其建立buffer
            merge_buf[i] = row_merge_buf_create(index[i])
            ->读取为innodb_sort_buffer_size 默认4M
         -> 从头开始读取主键 
            btr_pcur_open_at_index_side
         -> 循环每一个page,获取一个记录进行处理
            page_cur_move_to_next
            获取记录的游标
            page_cur_is_after_last(cur)
            是否是page的最后一条记录,使用supremum进行判定
            ->需要判断,是否占用了index lock
              rw_lock_get_waiters(dict_index_get_lock(clust_index)
              ->是,btr_pcur_move_to_prev_on_page(&pcur)
                先回复游标到上一次page
                os_thread_yield
                先暂时放弃CPU
              ->否,btr_page_get_next
                访问下一个page
                next_page_no == FIL_NULL
                如果下一个page为空则结束
            rec = page_cur_get_rec(cur);
            读取记录
            offsets = rec_get_offsets(rec, clust_index, nullptr, ULINT_UNDEFINED, &row_heap); 
            获取行的偏移量 
            if (online)
              是online,则
              trx->read_view->changes_visible 
              则需要改变行的可变性
              rec_get_deleted_flag
              如果是标记为删除的记录,则跳过
              不是online,则
              rec_get_deleted_flag
              如果是标记为删除的记录,则跳过
            row = row_build_w_add_vcol,实际调用为row_build_low
              建立新行,根据新建的语法,如果只是增加索引这里
              add_cols=0x0, add_v=0x0, col_map=0x0
              可以看到add cols没有具体的信息
              返回信息为dtupe_t类型,为一行根据新字段建立好的行
              已经转变为tupe类型
            ->for (ulint i = 0; i < n_nonnull; i++)
              循环所有的NOT NULL字段
              dfield_is_null(field)
              判断是否字段对应的值为NULL
              是则进行抛错处理
            ->是否需要设置自增值
              设置自增值
            ->skip_sort = skip_pk_sort && merge_buf[0]->index->is_clustered(); 
              如果为增加字段(非instant)第一次 cluster 不需要进行排序,
              如果增加的是单个索引则这里为 false,因为不是主键
            ->for (ulint i = 0; i < n_index; i++, skip_sort = false)
              循环每个需要新建的索引,这里注意条件skip_sort = false 
              除了cluster索引外其他的二级索引都需要排序
              
              ->row_merge_buf_add(通常返回0代表超过了srv_sort_buf_size大小,正常为1行处理完成) 
               对新加入的索引和现有行数据进行处理,并且写入到merge buffer中
               ->循环每一个字段
                 ->拷贝field
                 ->获取field长度
                 ->data_size += len
                   计算data总的长度
               判断总的data长度不能大于srv_sort_buf_size的大小
               如果buf->total_size + data_size >= srv_sort_buf_size - 1
                 是,则返回0(multi-value index特殊处理),也就是(row_merge_buf_t)buf中的大小
                 加上本次的数据大小大于了srv_sort_buf_size,就会返回
               ->循环每一个字段
                 将数据从field拷贝到buf->heap
               通常返回0代表超过了srv_sort_buf_size大小,正常为1行处理完成
              ->通过row_merge_buf_add的返回值进行判断
                ->如果返回为1,则进行下一轮循环,这里的循环是循环下一次需要重建的索引
                ->如果返回为0,则说明sort buffer满了需要进行排序了
              ->是否需要跳过排序(主键才会)
                ->是
                  ->row_merge_spatial_rows 和空间索引相关不考虑直接return
                  ->row_merge_insert_index_tuples
                    直接将记录插入到索引,跳过排序(一般这里是主键)
                    改变状态为srv_stage_alter_table_insert (alter table (insert))
                    显然这个状态会多次进入,如果有多个索引
                    ->for (;;)
                    循环sort buffer中的每行 
                    退出条件为行数大于了innobase sort buffer中的行数
                    ->row_merge_mtuple_to_dtuple
                      将每行转换为tuple格式
                    ->btr_bulk->insert(dtuple)
                      将dtuple以bulk方式插入,这是一个重点的行数
                      代表的了自底而上的插入方式。这里先跳过
                  ->清空innobase sort buffer
                ->否
                  ->是否是唯一索引
                    ->是
                      需要开启重复值判定
                      row_merge_buf_sort(buf, &dup);
                      进行排序
                    ->否
                      row_merge_buf_sort(buf, nullptr);
                      进行排序
                    -> if (row == nullptr && file->fd == -1 && !clust_temp_file) 
                      是否开启了临时文件,如果开启了说明需要写到
                      临时文件                
                      ->否
                        row_merge_insert_index_tuples
                        排序后进行插入,如上状态alter table (insert)
                      ->是
                        row_merge_file_create_if_needed
                        建立临时文件
                        row_merge_buf_write /tmp目录需要文件 写入block
                        row_merge_write(debug一下这里) /tmp目录需要文件 将block写入到merge文件
                        写入到临时文件,后面做merge排序合并   
      ->循环每个需要建立的索引
       ->merge_files[i].fd >= 0
        先判断是否有临时文件,如果没有则不需要merge_sort和insert_index_tuples
        因为前面已经插入了  
        ->row_merge_sort 输入为前面得到的tmpfd,也就是包含数据的临时文件
         大数据量表做merge排序,这里改变状态为 srv_stage_alter_table_merge_sort
        ->row_merge_insert_index_tuples
         见后面。是有bulk方式插入到索引,这里改变状态为 srv_stage_alter_table_insert
        ->row_merge_file_destroy(&merge_files[i])
         丢弃临时文件,可以看到这里online DDL通常
         需要临时文件的支持
       ->判断是否重建主键,如果是进行下面步骤
        ->FlushObserver::flush
          ->进入状态srv_stage_alter_table_flush
          ->buf_flush_get_dirty_pages_count
           ->循环每个pool,对操作的对象的space id查看
             需要刷新块
          ->buf_LRU_flush_or_remove_pages
           类型为BUF_REMOVE_FLUSH_WRITE
           ->根据类型判断是否需要维护AHI
             BUF_REMOVE_FLUSH_WRITE不需要维护AHI
           ->buf_LRU_flush_or_remove_pages
             类型为BUF_REMOVE_FLUSH_WRITE
             进行flush刷脏,需要回写脏数据到物理文件
             flush to disk if true but don't remove
             可见代码buf_flush_or_remove_page
             根据flush与否是否从buffer pool中去掉
        ->row_merge_write_redo
          写入redo MLOG_INDEX_LOAD
        ->row_log_apply
          ->stage->begin_phase_log_index()
            进入状态srv_stage_alter_table_log_index
          ->应用日志
      ->清理merge排序用到的临时文件
      先要判断是否重建了主键ctx->need_rebuild()
      如果是
      ->row_log_table_apply 
      进入状态:srv_stage_alter_table_log_table
      ->rw_lock_x_lock(dict_index_get_lock(clust_index));  
       先对主键index加锁
      ->row_log_table_apply_ops 
       分3层,循环1:
       循环1:访问一个block(sort buffer大小)
       ->判断是否当前block(sort buffer 大小)已经是最后一个block
         如果是则直接加锁应用最后一个block,同时这种情况肯定就在
         sort buffer内存了。
       ->如果不是则需要读取物理文件,读取block(sort buffer大小)同时解锁
         ,不影响正常的写入。
         ->循环2:
           获取block中的每行记录,应用。
           ->row_log_table_apply_op
             ->根据不同类型ROW_T_INSERT/ROW_T_DELETE/ROW_T_UPDATE
               分别应用,这里以insert为例
               ->row_log_table_apply_insert
                 ->row_log_table_apply_convert_mrec
                   转日志记录为tuple类型最好插入准备
                 ->row_log_table_apply_insert_low
                   ->row_ins_clust_index_entry_low
                     插入为先主键插入
                   ->循环3:
                     ->row_ins_sec_index_entry_low
                     循环每个二级索引插入
      ->rw_lock_x_unlock(dict_index_get_lock(clust_index)); 
        主键解锁
    

    8.0 增加索引 没有看到 data目录下的临时文件
    增加索引和add col一起看到了,并且很慢,全索引merge,
    3倍空间,data临时文件 tmp临时文件。

    -rw-r-----. 1 mysql mysql 335544320 Oct 17 23:43 tttoo.ibd
    -rw-r-----. 1 mysql mysql 92274688 Oct 17 23:49 #sql-ib1339-3955111351.ibd

    mysql> alter table tttoo add index(io);
    Query OK, 0 rows affected, 1 warning (1 min 1.46 sec)
    Records: 0 Duplicates: 0 Warnings: 1

    mysql> alter table tttoo add index(io),add ipp int;
    Query OK, 0 rows affected, 1 warning (7 min 52.48 sec)
    Records: 0 Duplicates: 0 Warnings: 1

    row_log_tmpfile 为打开临时文件的接口

    lrwx------. 1 root root 64 Oct 20 11:43 60 -> /newdata/mysql/mysql8023/tmp/#284070 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 59 -> /newdata/mysql/mysql8023/tmp/#284069 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 58 -> /newdata/mysql/mysql8023/tmp/#284068 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 57 -> /newdata/mysql/mysql8023/tmp/#284067 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 56 -> /newdata/mysql/mysql8023/tmp/#284066 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 55 -> /newdata/mysql/mysql8023/tmp/#284065 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 54 -> /newdata/mysql/mysql8023/tmp/#284059 (deleted)
    lrwx------. 1 root root 64 Oct 20 11:43 51 -> /newdata/mysql/mysql8023/data/test/#sql-ib1394-938072227.ibd
    lrwx------. 1 root root 64 Oct 20 11:43 50 -> /newdata/mysql/mysql8023/data/test/tttoo.ibd
    lrwx------. 1 root root 64 Oct 20 11:43 49 -> socket:[42365]
    lrwx------. 1 root root 64 Oct 20 11:43 48 -> /newdata/mysql/mysql8023/data/test/test.ibd
    lrwx------. 1 root root 64 Oct 20 11:43 46 -> socket:[35028]
    lrwx------. 1 root root 64 Oct 20 11:46 52 -> socket:[42886]
    (gdb) p log->fd
    $4 = 54
    
    [root@mgr4 fd]# lsof -p 5517|grep delete
    mysqld  5517 mysql   10u      REG               8,16      4856   262456 /newdata/mysql/mysql8023/tmp/#262456 (deleted)
    mysqld  5517 mysql   11u      REG               8,16         0   262460 /newdata/mysql/mysql8023/tmp/#262460 (deleted)
    mysqld  5517 mysql   12u      REG               8,16         0   262478 /newdata/mysql/mysql8023/tmp/#262478 (deleted)
    mysqld  5517 mysql   18u      REG               8,16         0   262479 /newdata/mysql/mysql8023/tmp/#262479 (deleted)
    mysqld  5517 mysql   54u      REG               8,16         0   284059 /newdata/mysql/mysql8023/tmp/#284059 (deleted)
    mysqld  5517 mysql   55u      REG               8,16  29360128   284065 /newdata/mysql/mysql8023/tmp/#284065 (deleted)
    mysqld  5517 mysql   56u      REG               8,16  29360128   284066 /newdata/mysql/mysql8023/tmp/#284066 (deleted)
    mysqld  5517 mysql   57u      REG               8,16  29360128   284067 /newdata/mysql/mysql8023/tmp/#284067 (deleted)
    mysqld  5517 mysql   58u      REG               8,16  29360128   284068 /newdata/mysql/mysql8023/tmp/#284068 (deleted)
    mysqld  5517 mysql   59u      REG               8,16  29360128   284069 /newdata/mysql/mysql8023/tmp/#284069 (deleted)
    mysqld  5517 mysql   60u      REG               8,16  29360128   284070 /newdata/mysql/mysql8023/tmp/#284070 (deleted)
    
    /newdata/mysql/mysql8023/tmp/#284059:为log日志文件,注意这些文件都是以sort参数大小为block大小的
    
    [root@mgr4 fd]# lsof -p 5517|grep delete
    mysqld  5517 mysql   10u      REG               8,16      4856   262456 /newdata/mysql/mysql8023/tmp/#262456 (deleted)
    mysqld  5517 mysql   11u      REG               8,16         0   262460 /newdata/mysql/mysql8023/tmp/#262460 (deleted)
    mysqld  5517 mysql   12u      REG               8,16         0   262478 /newdata/mysql/mysql8023/tmp/#262478 (deleted)
    mysqld  5517 mysql   18u      REG               8,16         0   262479 /newdata/mysql/mysql8023/tmp/#262479 (deleted)
    mysqld  5517 mysql   54u      REG               8,16   4194304   284059 /newdata/mysql/mysql8023/tmp/#284059 (deleted)
    mysqld  5517 mysql   56u      REG               8,16  29360128   284066 /newdata/mysql/mysql8023/tmp/#284066 (deleted)
    mysqld  5517 mysql   57u      REG               8,16  29360128   284067 /newdata/mysql/mysql8023/tmp/#284067 (deleted)
    mysqld  5517 mysql   58u      REG               8,16  29360128   284068 /newdata/mysql/mysql8023/tmp/#284068 (deleted)
    mysqld  5517 mysql   59u      REG               8,16  29360128   284069 /newdata/mysql/mysql8023/tmp/#284069 (deleted)
    mysqld  5517 mysql   60u      REG               8,16  29360128   284070 /newdata/mysql/mysql8023/tmp/#284070 (deleted)
    
    
    
    (gdb) bt
    #0  row_ins_clust_index_entry_low (flags=23, mode=33, index=0xc675ea0, n_uniq=1, entry=0x1f684778, thr=0xc4e8998, dup_chk_only=false)
        at /newdata/mysql-8.0.23/storage/innobase/row/row0ins.cc:2350
    #1  0x000000000515c01c in row_log_table_apply_insert_low (thr=0xc4e8998, row=0x1f684630, trx_id=447979, offsets_heap=0x1f688670, heap=0x1f684590, dup=0x7fffe47c8980)
        at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:1503
    #2  0x000000000515c327 in row_log_table_apply_insert (thr=0xc4e8998, mrec=0x7fff9c3f9003 "", offsets=0xc6a0360, offsets_heap=0x1f688670, heap=0x1f684590, dup=0x7fffe47c8980, trx_id=447979)
        at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:1587
    #3  0x000000000515e8ea in row_log_table_apply_op (thr=0xc4e8998, trx_id_col=1, new_trx_id_col=1, dup=0x7fffe47c8980, error=0x7fffe47c8594, offsets_heap=0x1f688670, heap=0x1f684590, 
        mrec=0x7fff9c3f9003 "", mrec_end=0x7fff9c7f9000 "", offsets=0xc6a0360) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:2390
    #4  0x00000000051604e6 in row_log_table_apply_ops (thr=0xc4e8998, dup=0x7fffe47c8980, stage=0xc6a0560) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:2925
    #5  0x00000000051609a2 in row_log_table_apply (thr=0xc4e8998, old_table=0xc341770, table=0xc4e5490, stage=0xc6a0560) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:3014
    #6  0x0000000004fb2b5e in ha_innobase::inplace_alter_table_impl<dd::Table> (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, old_dd_tab=0xc33dd78, 
        new_dd_tab=0xc4d1b08) at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:6143
    #7  0x0000000004f8d1b3 in ha_innobase::inplace_alter_table (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, old_dd_tab=0xc33dd78, new_dd_tab=0xc4d1b08)
        at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:1284
    #8  0x00000000038e1942 in handler::ha_inplace_alter_table (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, old_table_def=0xc33dd78, new_table_def=0xc4d1b08)
        at /newdata/mysql-8.0.23/sql/handler.h:5785
    #9  0x00000000038c5b36 in mysql_inplace_alter_table (thd=0xad622d0, schema=..., new_schema=..., table_def=0xc33dd78, altered_table_def=0xc4d1b08, table_list=0xc4c9c48, table=0xc359a90, 
        altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, alter_ctx=0x7fffe47ca3f0, columns=std::set with 0 elements, 
        fk_key_info=0xc514b80, fk_key_count=0, fk_invalidator=0x7fffe47ca320) at /newdata/mysql-8.0.23/sql/sql_table.cc:13008
    #10 0x00000000038d13eb in mysql_alter_table (thd=0xad622d0, new_db=0xc4ca260 "test", new_name=0x0, create_info=0x7fffe47cc210, table_list=0xc4c9c48, alter_info=0x7fffe47cc0a0)
        at /newdata/mysql-8.0.23/sql/sql_table.cc:16910
    #11 0x0000000003e778de in Sql_cmd_alter_table::execute (this=0xc4ca500, thd=0xad622d0) at /newdata/mysql-8.0.23/sql/sql_alter.cc:351
    #12 0x00000000037fa060 in mysql_execute_command (thd=0xad622d0, first_level=true) at /newdata/mysql-8.0.23/sql/sql_parse.cc:4407
    #13 0x00000000037fbf41 in dispatch_sql_command (thd=0xad622d0, parser_state=0x7fffe47cda50) at /newdata/mysql-8.0.23/sql/sql_parse.cc:4988
    #14 0x00000000037f2543 in dispatch_command (thd=0xad622d0, com_data=0x7fffe47ceb00, command=COM_QUERY) at /newdata/mysql-8.0.23/sql/sql_parse.cc:1836
    #15 0x00000000037f095e in do_command (thd=0xad622d0) at /newdata/mysql-8.0.23/sql/sql_parse.cc:1320
    #16 0x00000000039c5c91 in handle_connection (arg=0xacee820) at /newdata/mysql-8.0.23/sql/conn_handler/connection_handler_per_thread.cc:301
    #17 0x000000000562cd84 in pfs_spawn_thread (arg=0xab1c320) at /newdata/mysql-8.0.23/storage/perfschema/pfs.cc:2900
    #18 0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
    #19 0x00007ffff5e388dd in clone () from /lib64/libc.so.6
    
    
    #0  row_ins_sec_index_entry_low (flags=23, mode=33, index=0xc6771f0, offsets_heap=0x1f688670, heap=0x1f684590, entry=0x1f684960, trx_id=447979, thr=0xc4e8998, dup_chk_only=false)
        at /newdata/mysql-8.0.23/storage/innobase/row/row0ins.cc:2775
    #1  0x000000000515c14a in row_log_table_apply_insert_low (thr=0xc4e8998, row=0x1f684630, trx_id=447979, offsets_heap=0x1f688670, heap=0x1f684590, dup=0x7fffe47c8980)
        at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:1532
    #2  0x000000000515c327 in row_log_table_apply_insert (thr=0xc4e8998, mrec=0x7fff9c3f9003 "", offsets=0xc6a0360, offsets_heap=0x1f688670, heap=0x1f684590, dup=0x7fffe47c8980, trx_id=447979)
        at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:1587
    #3  0x000000000515e8ea in row_log_table_apply_op (thr=0xc4e8998, trx_id_col=1, new_trx_id_col=1, dup=0x7fffe47c8980, error=0x7fffe47c8594, offsets_heap=0x1f688670, heap=0x1f684590, 
        mrec=0x7fff9c3f9003 "", mrec_end=0x7fff9c7f9000 "", offsets=0xc6a0360) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:2390
    #4  0x00000000051604e6 in row_log_table_apply_ops (thr=0xc4e8998, dup=0x7fffe47c8980, stage=0xc6a0560) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:2925
    #5  0x00000000051609a2 in row_log_table_apply (thr=0xc4e8998, old_table=0xc341770, table=0xc4e5490, stage=0xc6a0560) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:3014
    #6  0x0000000004fb2b5e in ha_innobase::inplace_alter_table_impl<dd::Table> (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, old_dd_tab=0xc33dd78, 
        new_dd_tab=0xc4d1b08) at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:6143
    #7  0x0000000004f8d1b3 in ha_innobase::inplace_alter_table (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, old_dd_tab=0xc33dd78, new_dd_tab=0xc4d1b08)
        at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:1284
    #8  0x00000000038e1942 in handler::ha_inplace_alter_table (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, old_table_def=0xc33dd78, new_table_def=0xc4d1b08)
        at /newdata/mysql-8.0.23/sql/handler.h:5785
    #9  0x00000000038c5b36 in mysql_inplace_alter_table (thd=0xad622d0, schema=..., new_schema=..., table_def=0xc33dd78, altered_table_def=0xc4d1b08, table_list=0xc4c9c48, table=0xc359a90, 
        altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, alter_ctx=0x7fffe47ca3f0, columns=std::set with 0 elements, 
        fk_key_info=0xc514b80, fk_key_count=0, fk_invalidator=0x7fffe47ca320) at /newdata/mysql-8.0.23/sql/sql_table.cc:13008
    #10 0x00000000038d13eb in mysql_alter_table (thd=0xad622d0, new_db=0xc4ca260 "test", new_name=0x0, create_info=0x7fffe47cc210, table_list=0xc4c9c48, alter_info=0x7fffe47cc0a0)
        at /newdata/mysql-8.0.23/sql/sql_table.cc:16910
    #11 0x0000000003e778de in Sql_cmd_alter_table::execute (this=0xc4ca500, thd=0xad622d0) at /newdata/mysql-8.0.23/sql/sql_alter.cc:351
    #12 0x00000000037fa060 in mysql_execute_command (thd=0xad622d0, first_level=true) at /newdata/mysql-8.0.23/sql/sql_parse.cc:4407
    #13 0x00000000037fbf41 in dispatch_sql_command (thd=0xad622d0, parser_state=0x7fffe47cda50) at /newdata/mysql-8.0.23/sql/sql_parse.cc:4988
    #14 0x00000000037f2543 in dispatch_command (thd=0xad622d0, com_data=0x7fffe47ceb00, command=COM_QUERY) at /newdata/mysql-8.0.23/sql/sql_parse.cc:1836
    #15 0x00000000037f095e in do_command (thd=0xad622d0) at /newdata/mysql-8.0.23/sql/sql_parse.cc:1320
    #16 0x00000000039c5c91 in handle_connection (arg=0xacee820) at /newdata/mysql-8.0.23/sql/conn_handler/connection_handler_per_thread.cc:301
    #17 0x000000000562cd84 in pfs_spawn_thread (arg=0xab1c320) at /newdata/mysql-8.0.23/storage/perfschema/pfs.cc:2900
    #18 0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
    #19 0x00007ffff5e388dd in clone () from /lib64/libc.so.6
    

    row lock记录的类型。
    row_log_table_delete
    row_log_table_update
    row_log_table_insert

    delete记录比较少,主键+undoptr+DATA_TRX_ID_LEN = 没有主键就是20字节
    
    
    log过大ER_INNODB_ONLINE_LOG_TOO_BIG
    

    应用最后一部分:

    #0  row_log_table_apply_ops (thr=0xc4e8998, dup=0x7fffe47c80a0, stage=0xc6a0560) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:2661
    #1  0x00000000051609a2 in row_log_table_apply (thr=0xc4e8998, old_table=0xc341770, table=0xc4e5490, stage=0xc6a0560) at /newdata/mysql-8.0.23/storage/innobase/row/row0log.cc:3014
    #2  0x0000000004facbe2 in commit_try_rebuild (ha_alter_info=0x7fffe47c9510, ctx=0xc515b98, altered_table=0xc4e5490, old_table=0xc359a90, trx=0x7fffe5be9078, table_name=0xc34a3e5 "tttoo")
        at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:6836
    #3  0x0000000004fb3c09 in ha_innobase::commit_inplace_alter_table_impl<dd::Table> (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, commit=true, 
        old_dd_tab=0xc33dd78, new_dd_tab=0xc4d1b08) at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:7473
    #4  0x0000000004f8d34d in ha_innobase::commit_inplace_alter_table (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, commit=true, old_dd_tab=0xc33dd78, 
        new_dd_tab=0xc4d1b08) at /newdata/mysql-8.0.23/storage/innobase/handler/handler0alter.cc:1331
    #5  0x0000000003b77f6b in handler::ha_commit_inplace_alter_table (this=0xc33f6d8, altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, commit=true, old_table_def=0xc33dd78, 
        new_table_def=0xc4d1b08) at /newdata/mysql-8.0.23/sql/handler.cc:4879
    #6  0x00000000038c5cfc in mysql_inplace_alter_table (thd=0xad622d0, schema=..., new_schema=..., table_def=0xc33dd78, altered_table_def=0xc4d1b08, table_list=0xc4c9c48, table=0xc359a90, 
        altered_table=0xc4e5490, ha_alter_info=0x7fffe47c9510, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, alter_ctx=0x7fffe47ca3f0, columns=std::set with 0 elements, 
        fk_key_info=0xc514b80, fk_key_count=0, fk_invalidator=0x7fffe47ca320) at /newdata/mysql-8.0.23/sql/sql_table.cc:13050
    #7  0x00000000038d13eb in mysql_alter_table (thd=0xad622d0, new_db=0xc4ca260 "test", new_name=0x0, create_info=0x7fffe47cc210, table_list=0xc4c9c48, alter_info=0x7fffe47cc0a0)
        at /newdata/mysql-8.0.23/sql/sql_table.cc:16910
    #8  0x0000000003e778de in Sql_cmd_alter_table::execute (this=0xc4ca500, thd=0xad622d0) at /newdata/mysql-8.0.23/sql/sql_alter.cc:351
    #9  0x00000000037fa060 in mysql_execute_command (thd=0xad622d0, first_level=true) at /newdata/mysql-8.0.23/sql/sql_parse.cc:4407
    #10 0x00000000037fbf41 in dispatch_sql_command (thd=0xad622d0, parser_state=0x7fffe47cda50) at /newdata/mysql-8.0.23/sql/sql_parse.cc:4988
    #11 0x00000000037f2543 in dispatch_command (thd=0xad622d0, com_data=0x7fffe47ceb00, command=COM_QUERY) at /newdata/mysql-8.0.23/sql/sql_parse.cc:1836
    #12 0x00000000037f095e in do_command (thd=0xad622d0) at /newdata/mysql-8.0.23/sql/sql_parse.cc:1320
    #13 0x00000000039c5c91 in handle_connection (arg=0xacee820) at /newdata/mysql-8.0.23/sql/conn_handler/connection_handler_per_thread.cc:301
    #14 0x000000000562cd84 in pfs_spawn_thread (arg=0xab1c320) at /newdata/mysql-8.0.23/storage/perfschema/pfs.cc:2900
    #15 0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
    #16 0x00007ffff5e388dd in clone () from /lib64/libc.so.6
    

    相关文章

      网友评论

          本文标题:MySQL DDL简析(1):inplace DDL 主要st

          本文链接:https://www.haomeiwen.com/subject/lbwfaltx.html