Description:
In MySQL5.6.19, stats_latch is delayed to be created until it's used. So dummy table should never create stats_latch since it's not shared with other threads.
But still there are another two mutex not take into consideration
1.autoinc_mutex for dummy table
2.index->zip_pad.mutex for dummy index.
Because dummy table/index is not shared with other threads, So this overhead can be avoided completely
Actually same problem has been described in bug#71708 and Laurynas Biveinis even proved a patch to avoid autoinc_mutex creation for dummy table. Since bug#71708 is closed and I encountered this problem, I decide to open a new bug report.
How to repeat:
Under heavy io-intensive workload using MySQL5.6.19
In my test, using sysbench, 200 tables with 1,000,000 records each. Restart the server and adding update workload (using update_index.lua) without warming up the buffer pool. Then observed history length increased and you may find traces like this :
1 __lll_lock_wait(libpthread.so.0),_L_lock_995(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),os_fast_mutex_lock_func(os0sync.cc:873),pfs_os_fast_mutex_lock(os0sync.cc:873),os_mutex_enter(os0sync.cc:873),os_fast_mutex_free_func(os0sync.cc:925),pfs_os_fast_mutex_free(os0sync.ic:93),dict_mem_index_free(os0sync.ic:93),ibuf_dummy_index_free(ibuf0ibuf.cc:1574),ibuf_get_volume_buffered_count_func(ibuf0ibuf.cc:3066),ibuf_get_volume_buffered(ibuf0ibuf.cc:3137),ibuf_insert_low(ibuf0ibuf.cc:3137),ibuf_insert(ibuf0ibuf.cc:3913),btr_cur_search_to_nth_level(btr0cur.cc:625),row_ins_sec_index_entry_low(row0ins.cc:2655),row_ins_sec_index_entry(row0ins.cc:2938),row_upd_sec_index_entry(row0upd.cc:1840),row_upd_sec_step(row0upd.cc:1867),row_upd(row0upd.cc:1867),row_upd_step(row0upd.cc:1867),row_update_for_mysql(row0mysql.cc:1728),ha_innobase::update_row(ha_innodb.cc:7083),handler::ha_update_row(handler.cc:7298),mysql_update(sql_update.cc:818),mysql_execute_command(sql_parse.cc:3309),mysql_parse(sql_parse.cc:6247),dispatch_command(sql_parse.cc:1334),do_handle_one_connection(sql_connect.cc:982),handle_one_connection(sql_connect.cc:898),pfs_spawn_thread(pfs.cc:1860),start_thread(libpthread.so.0),clone(libc.so.6)
1 __lll_lock_wait(libpthread.so.0),_L_lock_995(libpthread.so.0),pthread_mutex_lock(libpthread.so.0),os_fast_mutex_lock_func(os0sync.cc:873),pfs_os_fast_mutex_lock(os0sync.cc:873),os_mutex_enter(os0sync.cc:873),os_fast_mutex_init_func(os0sync.cc:852),pfs_os_fast_mutex_init(os0sync.ic:74),dict_mem_index_create(os0sync.ic:74),ibuf_dummy_index_create(ibuf0ibuf.cc:1537),ibuf_build_entry_from_ibuf_rec_func(ibuf0ibuf.cc:1537),ibuf_get_volume_buffered_count_func(ibuf0ibuf.cc:3062),ibuf_get_volume_buffered(ibuf0ibuf.cc:3137),ibuf_insert_low(ibuf0ibuf.cc:3137),ibuf_insert(ibuf0ibuf.cc:3913),btr_cur_search_to_nth_level(btr0cur.cc:638),btr_pcur_open_low(btr0pcur.ic:440),row_search_index_entry(btr0pcur.ic:440),row_upd_sec_index_entry(row0upd.cc:1752),row_upd_sec_step(row0upd.cc:1867),row_upd(row0upd.cc:1867),row_upd_step(row0upd.cc:1867),row_update_for_mysql(row0mysql.cc:1728),ha_innobase::update_row(ha_innodb.cc:7083),handler::ha_update_row(handler.cc:7298),mysql_update(sql_update.cc:818),mysql_execute_command(sql_parse.cc:3309),mysql_parse(sql_parse.cc:6247),dispatch_command(sql_parse.cc:1334),do_handle_one_connection(sql_connect.cc:982),handle_one_connection(sql_connect.cc:898),pfs_spawn_thread(pfs.cc:1860),start_thread(libpthread.so.0),clone(libc.so.6)
result from perf record:
- 1.16% mysqld mysqld [.] os_mutex_enter(os_mutex_t*) ▒
- os_mutex_enter(os_mutex_t*) ▒
- 33.66% os_fast_mutex_free_func(pthread_mutex_t*) ▒
- 54.88% os_event_free(os_event*) ▒
mutex_free_func(ib_mutex_t*) ▒
+ dict_mem_table_free(dict_table_t*) ▒
- 45.12% dict_mem_index_free(dict_index_t*) ▒
+ 94.39% ibuf_dummy_index_free(dict_index_t*) ▒
+ 4.18% ibuf_merge_or_delete_for_page(buf_block_t*, unsigned long, unsigned long, unsigned long, unsigned long) ▒
+ 1.43% ibuf_rec_get_volume_func(unsigned char const*) ▒
- 32.46% os_event_create() ▒
mutex_create_func(ib_mutex_t*, char const*, unsigned long) ▒
dict_mem_table_create(char const*, unsigned long, unsigned long, unsigned long, unsigned long) ▒
+ ibuf_build_entry_from_ibuf_rec_func(unsigned char const*, mem_block_info_t*, dict_index_t**) ▒
+ 18.62% os_fast_mutex_init_func(pthread_mutex_t*) ▒
+ 14.57% os_event_free(os_event*)
Suggested fix:
N/A