在性能差的磁盘上,执行上面命令是有风险的,执行上面的命令过程中,会purge未在index 文件中的binlog ,如果过多,清理的时间慢,持有的Lock_log时间过长,会阻塞dml。这个风险点相对较高,一般线上机器磁盘性能高不会遇到这个问题,但是需要注意这个风险点。 调用栈如下:
MYSQL_BIN_LOG::purge_index_entry(THD*, unsigned long long*, bool) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/binlog.cc:6832) MYSQL_BIN_LOG::open_index_file(char const*, char const*, bool) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/binlog.cc:4129) MYSQL_BIN_LOG::new_file_impl(bool, Format_description_log_event*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/binlog.cc:7639) MYSQL_BIN_LOG::new_file_without_locking(Format_description_log_event*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/binlog.cc:7485) MYSQL_BIN_LOG::rotate(bool, bool*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/binlog.cc:8165) MYSQL_BIN_LOG::rotate_and_purge(THD*, bool) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/binlog.cc:8240) reload_acl_and_cache(THD*, unsigned long, TABLE_LIST*, int*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/sql_reload.cc:169) mysql_execute_command(THD*, bool) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/sql_parse.cc:4469) mysql_parse(THD*, Parser_state*, bool) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/sql_parse.cc:5927) dispatch_command(THD*, COM_DATA const*, enum_server_command) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/sql_parse.cc:1539) do_command(THD*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/sql_parse.cc:1060) threadpool_process_request(THD*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/threadpool_common.cc:260) handle_event(connection_t*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/threadpool_unix.cc:1584) worker_main(void*) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/sql/threadpool_unix.cc:1636) ::pfs_spawn_thread(void *) (/Users/xiaoyu.bai/Downloads/percona-server-5.7.29-32/storage/perfschema/pfs.cc:2198) _pthread_start (@_pthread_start:54) thread_start (@thread_start:8)
