为什么有时候binlog文件会很大于max_binlog_size以及max_binlog_
问题描述线上一个很有意思的现象,发现binlog文件大小是15G,查看了参数 第二个问题,以上面的设置为例,在文件快到1G的时候,如果来了一个大事务,这个大事务接近20G,那么是不是可以任务binlog文件的最大可能值是接近1G+20G=21G呢,因为超过max_binlog_cache_size就会报错了。这个也是可以测试下的。 实验证明问题1:实验测试 root@test10:39:24>set global max_binlog_size=4096; root@test10:48:23>begin; Query OK,0 rows affected (0.00 sec) root@test10:48:39>insert into testb select * from testa limit 32; Query OK,32 rows affected (0.00 sec) Records: 32 Duplicates: 0 Warnings: 0 root@test10:49:05>insert into testb select * from testa limit 32; Query OK,32 rows affected (0.00 sec) Records: 32 Duplicates: 0 Warnings: 0 root@test10:49:10>insert into testb select * from testa limit 32; Query OK,32 rows affected (0.00 sec) Records: 32 Duplicates: 0 Warnings: 0 root@test10:49:14>insert into testb select * from testa limit 32; Query OK,32 rows affected (0.00 sec) Records: 32 Duplicates: 0 Warnings: 0 root@test10:49:18>commit; Query OK,0 rows affected (0.00 sec) # at 3994? -- 上一个event结束的地方 ? ?问题2:实验测试 root@test11:01:52>set global max_binlog_cache_size=4096; ? 在实验的过程中遇见一个新问题 root@test11:07:21>insert into testb select * from testb limit 400; # at 331 能正常插入证明内存中产生的binlog应该是小于4096的,但是实际在binlog中看见的确实7286,明显是比4094大的,为啥会这样呢,在从内存中把binlog落盘的过程中做了什么处理吗? ? root@test11:21:01>show create table testbG *************************** 1. row *************************** Table: testb Create Table: CREATE TABLE `testb` ( `a` bigint(20) DEFAULT NULL,`b` bigint(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci 1 row in set (0.00 sec) [email?protected]:24:10>select version(); 以上是表结构以及MySQL的版本 ? 如有任何问题,欢迎指正。 参考文献: https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_max_binlog_size (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |