1197多语句事务要求更大的max_binlog_cache_size报错
  binlog_cache_size:为每个session 分配的内存,在事务过程中用来存储二进制日志的缓存,提高记录bin-log的效率。没有什么大事务,dml也不是很频繁的情况下可以设置小一点,如果事务大而且多,dml操作也频繁,则可以适当的调大一点。
max_binlog_cache_size设置的参考标准
  Binlog_cache_disk_use表示因为我们binlog_cache_size设计的内存不足导致缓存二进制日志用到了临时文件的次数;Binlog_cache_use 表示用binlog_cache_size缓存的次数,当对应的Binlog_cache_disk_use 值比较大的时候 我们可以考虑适当的调高 binlog_cache_size 对应的值
【故障情景】
  通过脚本以load的方式导入数据时,出现多行事务需要的max_binlog_cache_size空间不足。该数据文件HAOHUAN.txt只包含以逗号分隔的500万行左右的数据,每行四列,文件大小为270M。
 [root@172-16-3-190 shells]# bash +x load_data_into.sh
文件的总数为:1
文件名为:/tmp/load/HAOHUAN.txt
当前正在处理的文件是:/tmp/load/HAOHUAN.txt
load data infile '/tmp/load/HAOHUAN.txt' into table practice.temp_baofoo_unbind fields terminated by ',' lines terminated by '\n' (merchant_no,bank_code,bank_card,protocol_no)
Warning: Using a password on the command line interface can be insecure.
ERROR 1197 (HY000) at line 1: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again
【故障排查】
  查看max_binlog_cache_size的大小,发现数据文件的大小确实较max_binlog_cache_size的值要小,如果max_binlog_cache_size的大小不足以存放事务的binlog,那么会临时使用磁盘临时文件来存放binlog,通过查看Binlog_cache_disk_use发现使用临时文件存放的次数为1。因此增大max_binlog_cache_size的值到300M,再次执行脚本发现还是报相同的错误。且使用临时文件的次数为2,使用临时文件的存放binlog的总次数也相应由15增加到了16次。
 mysql> show global variables like '%binlog_cache%';
+-----------------------+-----------+
| Variable_name | Value |
+-----------------------+-----------+
| binlog_cache_size | 16777216 |
| max_binlog_cache_size | 268435456 |
+-----------------------+-----------+
2 rows in set (0.00 sec) mysql> show global status like '%binlog_cache%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Binlog_cache_disk_use | 1 |
| Binlog_cache_use | 15 |
+-----------------------+-------+
2 rows in set (0.00 sec) mysql> set @@global.max_binlog_cache_size=300000000;
Query OK, 0 rows affected, 1 warning (0.00 sec) [root@172-16-3-190 shells]# bash +x load_data_into.sh
文件的总数为:1
文件名为:/tmp/load/HAOHUAN.txt
当前正在处理的文件是:/tmp/load/HAOHUAN.txt
load data infile '/tmp/load/HAOHUAN.txt' into table practice.temp_baofoo_unbind fields terminated by ',' lines terminated by '\n' (merchant_no,bank_code,bank_card,protocol_no)
Warning: Using a password on the command line interface can be insecure.
ERROR 1197 (HY000) at line 1: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again mysql> show global status like '%binlog_cache%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Binlog_cache_disk_use | 2 |
| Binlog_cache_use | 16 |
+-----------------------+-------+
2 rows in set (0.00 sec)

无奈直接增加max_binlog_cache_size的值到500M时问题才解决(后经test实际给到400M也可以load成功),但是slave上的值没有及时改动,因而SQL同步线程报错,stop同步线程,同master一样的更改后,同步才算正常

 mysql> set @@global.max_binlog_cache_size=500000000;
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.3.190
Master_User: repl
Master_Port: 3309
Connect_Retry: 30
Master_Log_File: binlog.000018
Read_Master_Log_Pos: 120
Relay_Log_File: relay_bin.000006
Relay_Log_Pos: 6973
Relay_Master_Log_File: binlog.000017
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1197
Last_Error: Could not execute Write_rows event on table practice.temp_baofoo_unbind; Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again, Error_code: 1197; Writing one row to the row-based binary log failed, Error_code: 1534; handler error HA_ERR_RBR_LOGGING_FAILED; the event's master log binlog.000017, end_log_pos 268602107
Skip_Counter: 0
Exec_Master_Log_Pos: 11408
Relay_Log_Space: 333526981
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 208
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1197
Last_SQL_Error: Could not execute Write_rows event on table practice.temp_baofoo_unbind; Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again, Error_code: 1197; Writing one row to the row-based binary log failed, Error_code: 1534; handler error HA_ERR_RBR_LOGGING_FAILED; the event's master log binlog.000017, end_log_pos 268602107
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1903309
Master_UUID: 1b589d80-f450-11e7-9150-525400f4ecb2
Master_Info_File: /opt/app/mysql_3309/logs/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Reading event from the relay log
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 180803 17:39:08
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec) mysql> stop slave;
Query OK, 0 rows affected (1 min 10.64 sec)
【故障总结】
  max_binlog_cache_size参数时动态参数,该值的设置可以参考binlog_cache_use的大小来相应增加。load导入或者delete数据的大小必须要大于max_binlog_cache_size的值,多行事务才能成功执行。该参数值修改后,注意要与配置文件中的值大小一致。

1197多行事务要求更大的max_binlog_cache_size处理与优化的更多相关文章

  1. 分享工作中遇到的问题积累经验 事务日志太大导致insert不进数据

    分享工作中遇到的问题积累经验 事务日志太大导致insert不进数据 今天开发找我,说数据库insert不进数据,叫我看一下 他发了一个截图给我 然后我登录上服务器,发现了可疑的地方,而且这个数据库之前 ...

  2. 在.NET中快速创建一个5GB、10GB或更大的空文件

    对于通过UDP进行打文件传输的朋友应该首先会考虑到一个问题,那就是由于UDP并不会根据先来先到原则进行发送,也许你发送端发送的时候是以包1和包2的顺序传输的,但接收端可能以包2和包1 的顺序来进行接收 ...

  3. 把二叉搜索树转化成更大的树 · Convert BST to Greater Tree

    [抄题]: 给定二叉搜索树(BST),将其转换为更大的树,使原始BST上每个节点的值都更改为在原始树中大于等于该节点值的节点值之和(包括该节点). Given a binary search Tree ...

  4. error C3859: 超过了PCH的虚拟内存范围;请使用“-Zm33”或更大的命令行选项重新编译

    编译 ORB_SLAM的Release版本时,出现了此问题: 错误 2 error C3859: 超过了 PCH 的虚拟内存范围;请使用"-Zm465"或更大的命令行 修改方法: ...

  5. sqlserver 事务日志过大 收缩方法解决方案

    sqlserver 事务日志过大,可能会导致备份失败或者数据库出现异常,所以要定期清除sqlserver 事务日志 建议:为了防止日志文件无限扩大,可以对日志文件作一些限制. 清除sqlserver事 ...

  6. 梭子鱼:APT攻击是一盘更大的棋吗?

    随着企业对IT的依赖越来越强,APT攻击可能会成为一种恶意打击竞争对手的手段.目前,APT攻击目标主要有政治和经济目的两大类.而出于经济目的而进行的APT攻击可以获取竞争对手的商业信息,也可使用竞争对 ...

  7. Qt带来的是更加低廉的开发成本和学习成本,对于很多小公司而言,这种优势足以让他们获得更大的利润空间 good

    不能单纯从技术上来看待这个问题,Qt本来是小众的开发平台,个人认为,它的出现只是解决特性场景的特定问题,Qt带来的是更加低廉的开发成本和学习成本,对于很多小公司而言,这种优势足以让他们获得更大的利润空 ...

  8. [Swift]LeetCode496. 下一个更大元素 I | Next Greater Element I

    You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...

  9. [Swift]LeetCode503. 下一个更大元素 II | Next Greater Element II

    Given a circular array (the next element of the last element is the first element of the array), pri ...

随机推荐

  1. python 调用shell hive sql

    def generate_csv_source(data_file): #判断文件是否存在 if not os.path.exists(data_file): # 拉取hive表数据 cmd_sql ...

  2. 第七周助教工作总结——NWNU李泓毅

    本周应批改作业0,实批改作业0 因本周开始软工团队项目,故本周几位助教正在制定团队项目题目并且处理相关工作. 这一次的作业将于4月17日前进行提交,作业为软件研发团队的组建.

  3. python中使用XPath

    XPath在Python的爬虫学习中,起着举足轻重的地位,对比正则表达式 re两者可以完成同样的工作,实现的功能也差不多,但XPath明显比re具有优势,在网页分析上使re退居二线. XPath介绍: ...

  4. MUI动态生成轮播图片

    $$.ajax({ url:'http://localhost:8080/api/v1/food/listFeatureFood', type:'Get', xhrFields: {withCrede ...

  5. STM32CubeMX HAL库串口+DMA数据发送不定长度数据接收

    参考资料:1.ST HAL库官网资料 2.https://blog.csdn.net/u014470361/article/details/79206352#comments 一.STM32CubeM ...

  6. Exp5 MSF基础运用 20154320 李超

    实验后回答问题 用自己的话解释什么是exploit,payload,encode. exploit:起运输的作用,将数据传输到对方主机. payload:其实就是指装载的“具体内容”.就相当于shel ...

  7. win7里linux虚拟机安装vmware tools(ubuntu12.04)

    安装Vmware Tools工具 1.安装linux虚拟机(略) 2.虚拟机去启动,选择虚拟机à设置,“硬件”中选择CD/DVD(IDE),右侧选择“使用ISO镜像文件(M)”  -- 文件选择vmw ...

  8. 快速入门Vue

    前端技术发展很快,近日一个项目中想用Vue框架,对此对Vue基础进行了一些学习整理 何为Vue,官网 解释Vue.js(读音 /vjuː/,类似于 view) 是一套构建用户界面的渐进式框架 这里记录 ...

  9. linux 硬盘

    df -hT 查看格式 各种文件 mount命令 可以挂载那些块设备:光盘.磁盘分区.U盘 光盘:文件系统:iso9660 iso文件文件系统:iso9660 iso文件可以进行挂载的 mount c ...

  10. SSM_CRUD新手练习(10)返回分页的JSON数据

    我们完成了员工的分页查询,但是现在这种做法只能适应浏览器和服务器的交互模式,但在移动互联网时代,客户端不仅仅只有浏览器,还有安卓和IOS客户端.我们的解决方式是AJAX+JSON方式来实现平台无关性. ...