暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

binlog.9999999之后会发生什么

黄江平 2025-01-19
213

首先需要构造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文件,
image.png

再执行flush logs,
image.png
可以看到binlog.9999999会加1递增。

binlog的文件名长度是512字节,要把binlog全部用完,那是很大的一个数。
这是代码中写死的
image.png

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论