Concurrent inserts on MyISAM and the binary log
Recently I had an interesting surprise with concurrent inserts into a MyISAM table. The inserts were not happening concurrently with SELECT statements; they were blocking and the process list was filling up with queries in Locked status.
My first thought was that the customer had deleted from the table, which leaves “holes” in the middle of it and prevents concurrent inserts. (You can configure the server to permit concurrent inserts even when there are holes, but it’s disabled by default.) However, that turned out not to be the cause; the table was only inserted into (and selected from). Instead, the blocked statements were because of INSERT… SELECT statements that were running against the table, selecting data from it and inserting into another table.
Let’s look at what happens here: suppose you have two tables tbl1 and tbl2 and concurrent inserts into tbl2 are running fine. If you now run the following query,
INSERT INTO tbl1 SELECT * FROM tbl2
The concurrent inserts into tbl2 can block. This happens if you have the binary log enabled. If you think about it, this makes sense and is correct behavior. The statements have to be serialized for the binary log; otherwise replaying the binary log can result in a different order of execution.
The MySQL manual actually says this, but not in the clearest way. It just says
If you are using the binary log, concurrent inserts are converted to normal inserts for CREATE … SELECT or INSERT … SELECT statements.
If you use mysqladmin debug, you’ll see an ordinary SELECT gets a lock on the table like this:
Locked - read Low priority read lock
But on INSERT…SELECT, you’ll see this:
Read lock without concurrent inserts
That read lock is what’s blocking the concurrent inserts from happening.
There’s no solution to this, if you need the binary log enabled. (It needs to be enabled for replication.) There are workarounds, though. You can use the old trick of SELECT INTO OUTFILE followed by LOAD DATA INFILE. You can use InnoDB instead. Or you can do something more elaborate and application-specific, but that’s a topic for another post.
参考:
http://www.percona.com/blog/2008/05/14/concurrent-insert-select-myisam/
Concurrent inserts on MyISAM and the binary log的更多相关文章
- How to turn off the binary log for mysqld_multi instances?
Q: MySQL supports running multiple mysqld on the same server. One of the ways is to use mysqld_multi ...
- MySQL二进制日志(binary log)总结
本文出处:http://www.cnblogs.com/wy123/p/7182356.html (保留出处并非什么原创作品权利,本人拙作还远远达不到,仅仅是为了链接到原文,因为后续对可能存在的一些错 ...
- mysql二进制文件操作语法(mysql binary log operate statements)
开启 binary logs 功能 在 mysql 配置文件中配置 log-bin,重启 mysql my.cnf (on Linux/unix) or my.ini (on Windows) 例子: ...
- 【MySQL】MySQL同步报错-> Last_IO_Error: Got fatal error 1236 from master when reading data from binary log
这个报错网上搜索了一下,大部分是由于MySQL意外关闭或强制重启造成的binlog文件事务点读取异常造成的主从同步报错 Last_IO_Error: Got fatal error 1236 from ...
- [MySQL复制异常]'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.'
MySQL复制错误]Last_Errno: 1666 Last_Error: Error executing row event: 'Cannot execute statement: imposs ...
- mysql 主从 Got fatal error 1236 from master when reading data from binary log: 'Could not find first 错误
本地MySQL环境,是两台MySQL做M-M复制.今天发现错误信息: mysql 5.5.28-log> show slave status\G ************************ ...
- 17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 得到复制master binary log 位置:
17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 得到复制master binary log 位置: 你需要master ...
- 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log 使用binay log 基于时间点恢复
7.5 Point-in-Time (Incremental) Recovery Using the Binary Log 使用binay log 基于时间点恢复 7.5.1 Point-in-Tim ...
- MySQL 二进制日志(Binary Log)
同大多数关系型数据库一样,日志文件是MySQL数据库的重要组成部分. MySQL有几种不同的日志文件.通常包括错误日志文件,二进制日志,通用日志,慢查询日志,等等.这些日志能够帮助我们定位mysqld ...
随机推荐
- 团队SCRUM会议(第一次)
每日Scrum:第一天 会议时间:4.30.晚八点半 会议地点:基础教学楼一楼大厅 小组成员:郭庆樑,林彦汝,张金 团队PM:张金 会议进程 • 首先我们讨论了实验第一个Sprint1要实现的功能,我 ...
- mysql 批量创建表,利用存储过程
最近根据需求,需要提前创建一批日志表,以日期结尾,每天创建一张,例如XXX20160530,请参考如下: BEGIN DECLARE `sName` VARCHAR(128); DECLAR ...
- C++ offsetof
这是一个宏,用于计算类中某个成员的地址相对于类实例的偏移量 在C++11中,要求这个类standard_layout 基本用法是这样子的: #include <stdio.h> /* pr ...
- C#导入EXCEL数据
public static void InputUserFromExcel(string filePath) { string FileExName = filePath.Substring(file ...
- jsp弹出Please check the location and try again!对话框
关闭它的jsp图形模式.myeclipse10中打开jsp文件时,右键open with 选MyEclipse JSP Editor,不选MyEclipse Visual JSP Editor模式.
- Python ~~~ 面向对象的利器
class Rectangle(): # 有没有括号都行 . def __init__(self,x,y): self.x=x self.y=y def getPeri(self): def getA ...
- APP推广入门之AppStore数据分析
AppStore中有很多数据,但对于一个App推广者而言,最需要关注的无非这么几个,即下载量.评论.权重.榜单排名.搜索排名以及热词搜索等.至于这些数据具体代表着什么,下面就先由下载量开始,来简单介绍 ...
- win7登入使用的是临时档案解决方法
开始——运行(搜索程序与文件)——regedit——HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileLis ...
- PHP 防范CC攻击
CC攻击就是对方利用程序或一些代理对您的网站进行不间断的访问,造成您的网站处理不了而处于当机状态,下面是PHP方法:将以下代码另存为php文件,然后首行include入你的common.php文件中. ...
- ui-bootstrap-tpls-0.11.0.min.js