首先需要构造binlog.9999999,就需要借助gdb
在binlog.cc打断点
(gdb) b open_binlog
Breakpoint 1 at 0x47e93d9: open_binlog. (2 locations)
在mysql客户端执行flush logs;
mysql> flush logs;
这里触发断点
Thread 38 “connection” hit Breakpoint 1.1, MYSQL_BIN_LOG::open_binlog (this=0x8bf11c0 <mysql_bin_log>, log_name=0x14f5621f09e0 “binlog”,
new_name=0x14f5ca0e7d90 “./binlog.1000037”, max_size_arg=1073741824, null_created_arg=true, need_lock_index=false, need_sid_lock=true,
extra_description_event=0x0, new_index_number=0) at /usr/local/mysql-8.0.36/sql/binlog.cc:4859
4859 assert(need_sid_lock || !need_lock_index);
(gdb) p new_name
$21 = 0x14f5ca0e7d90 “./binlog.1000037”
可以看到现在的binlog文件是binlog.1000037,现在开始构造binlog.9999999
(gdb) p new_name[9]=‘9’
$22 = 57 ‘9’
(gdb) p new_name[10]=‘9’
$23 = 57 ‘9’
(gdb) p new_name[11]=‘9’
$24 = 57 ‘9’
(gdb) p new_name[12]=‘9’
$25 = 57 ‘9’
(gdb) p new_name[13]=‘9’
$26 = 57 ‘9’
(gdb) p new_name[14]=‘9’
$27 = 57 ‘9’
(gdb) p new_name[15]=‘9’
$28 = 57 ‘9’
(gdb) p new_name
$29 = 0x14f5ca0e7d90 “./binlog.9999999”
可以看到已构造出binlog.9999999。
查看binlog文件,

再执行flush logs,

可以看到binlog.9999999会加1递增。
binlog的文件名长度是512字节,要把binlog全部用完,那是很大的一个数。
这是代码中写死的





