pt-osc测试
pt-osc测试
1、原表必须存在主键 PRIMARY KEY 或者 UNIQUE KEY
The new table `darren`.`_t_user_new` does not have a PRIMARY KEY or a unique index which is required for the DELETE trigger.
Please check you have at least one UNIQUE and NOT NULLABLE index.
2、支持有外键约束的表,需要加上--alter-foreign-keys-method=rebuild_constraints参数
3、默认原表不能存在触发器。但是需要--preserve-triggers变量,不建议这么做,可能存在风险
The table `test`.`foo` has triggers but --preserve-triggers was not specified.
4、在pt-osc的执行过程中,如果有对主键的更新操作则会出现重复的数据,在3.02版本中已经修复
3.02之前:
更新触发器对应的sql语句:REPLACE INTO $new_tbl->{name} ($qcols) VALUES ($new_vals);
3.02之后:
DELETE IGNORE FROM $new_tbl->{name} WHERE !($upd_index_cols) AND $del_index_cols;
REPLACE INTO $new_tbl->{name} ($qcols) VALUES ($new_vals);
5、innodb_autoinc_lock_mode=1测试
当innodb_autoinc_lock_mode =1:
对于 bulk inserts,使用传统表锁的 AUTO-INC Locking 方式。
------------------------
LATEST DETECTED DEADLOCK
------------------------
2018-10-24 16:44:13 0x7f93585e3700
*** (1) TRANSACTION:
TRANSACTION 275263782, ACTIVE 0 sec setting auto-inc lock
mysql tables in use 2, locked 2
LOCK WAIT 4 lock struct(s), heap size 1136, 1 row lock(s), undo log entries 2
MySQL thread id 190, OS thread handle 140269612435200, query id 20289531 10.126.126.164 darren update
REPLACE INTO `sbtest`.`_sbtest1_new` (`id`, `c4`, `k`, `c`, `pad`, `c3`, `c5`, `c6`, `c7`, `c14`, `c9`, `c10`) VALUES (NEW.`id`, NEW.`c4`, NEW.`k`, NEW.`c`, NEW.`pa
d`, NEW.`c3`, NEW.`c5`, NEW.`c6`, NEW.`c7`, NEW.`c14`, NEW.`c9`, NEW.`c10`)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
TABLE LOCK table `sbtest`.`_sbtest1_new` trx id 275263782 lock mode AUTO-INC waiting
*** (2) TRANSACTION:
TRANSACTION 275263754, ACTIVE 0 sec fetching rows, thread declared inside InnoDB 4212
mysql tables in use 2, locked 2
258 lock struct(s), heap size 41168, 17913 row lock(s), undo log entries 17886
MySQL thread id 204, OS thread handle 140270819489536, query id 20289201 10.126.126.164 darren Sending data
INSERT LOW_PRIORITY IGNORE INTO `sbtest`.`_sbtest1_new` (`id`, `c4`, `k`, `c`, `pad`, `c3`, `c5`, `c6`, `c7`, `c14`, `c9`, `c10`) SELECT `id`, `c4`, `k`, `c`, `pad`
, `c3`, `c5`, `c6`, `c7`, `c14`, `c9`, `c10` FROM `sbtest`.`sbtest1` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= '1481317')) AND ((`id` <= '1506548')) LOCK IN SHARE MODE
/*pt-online-schema-change 69839 copy nibble*/
*** (2) HOLDS THE LOCK(S):
TABLE LOCK table `sbtest`.`_sbtest1_new` trx id 275263754 lock mode AUTO-INC
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 15248 page no 25707 n bits 152 index PRIMARY of table `sbtest`.`sbtest1` trx id 275263754 lock mode S locks rec but not gap waiting
Record lock, heap no 40 PHYSICAL RECORD: n_fields 15; compact format; info bits 0
0: len 8; hex 000000000016e050; asc P;;
1: len 6; hex 000010683126; asc h1&;;
2: len 7; hex 01000007722b37; asc r+7;;
3: len 1; hex 30; asc 0;;
4: len 4; hex 00385728; asc 8W(;;
5: len 30; hex 34313331333339383035342d30323832343038383036372d383038353233; asc 41313398054-02824088067-808523; (total 119 bytes);
6: len 30; hex 34393730393732313932382d31333738353836373533322d393836313330; asc 49709721928-13785867532-986130; (total 59 bytes);
7: len 4; hex 80000000; asc ;;
8: len 1; hex 30; asc 0;;
9: len 1; hex 30; asc 0;;
10: len 1; hex 30; asc 0;;
11: len 1; hex 30; asc 0;;
12: len 4; hex 80000000; asc ;;
13: len 4; hex 80000000; asc ;;
14: len 4; hex 80000000; asc ;;
*** WE ROLL BACK TRANSACTION (1)
【分析】
根据死锁信息可以得到 2个信息:
(1)事务1在等待"_sbtest1_new"表的AUTO-INC表锁;
(2)事务2持有"_sbtest1_new"的AUTO-INC表锁,等待"sbtest1"的记录锁。
事务1的replace into语句,明显是跑pt-osc创建的触发器产生的,当原表产生记录更新时,
触发器并将记录以replace方式同步到新表。
事务1:
(1)根据条件更新,对sbtest1持有排他的RECORD LOCKS;
(2)更新后触发器被触发,再以replace的方式插入_sbtest1_new表,需要对_sbtest1_new持有一个隐式的自增锁。
事务2:
(1)insert into select from,首先对_sbtest1_new加上了表级的自增锁;
(2)对新表加上表锁后,再根据条件中主键id的范围区间去申请原表sbtest1的记录锁。
由上,由于事务1先更新原表sbtest1,对更新的记录加上排它锁,触发器还没触发时,
事务2开始执行,这个时候事务2现对新表加表锁,当它再去申请对原表加记录级别的共享锁时,
发现部分记录被加上了排他锁,所以需要等待。这时事务1触发器触发了,需要对新表获取一个自增锁,造成了回环,产生死锁。
pt-osc测试的更多相关文章
- 素数与Miller-Rabin测试
素数及其性质 素数又称质数.指整数在一个大于 111 的自然数中,除了 111 和此整数自身外,没法被其他自然数整除的数. 性质1 有无穷多个素数. 证明: 用反证法.设已知的最大素数为 PPP,考虑 ...
- WCF-复合类型使用;传输图片
一:WCF服务端 IService1.cs中: public interface IService1 { [OperationContract] [WebInvoke(Method = "P ...
- C语言 栈 顺序结构 实现
一个能够自动扩容的顺序结构的栈 ArrStack 实例 (GCC编译). /** * @brief C语言实现的顺序结构类型的栈 * @author wid * @date 2013-10-29 * ...
- C语言 线性表 链式表结构 实现
一个单链式实现的线性表 mList (GCC编译). /** * @brief 线性表的链式实现 (单链表) * @author wid * @date 2013-10-21 * * @note 若代 ...
- boost::xml——基本操作以及中文乱码解决方案
下面是本人使用boost库的xml部分的基础操作,并且解决对于大家使用boost库读写中文xml内容出现的乱码问题. 1.实现boost库xml基本操作2.解决boost对xml中中文乱码问题3.实现 ...
- 【web安全】第三弹:web攻防平台pentester安装及XSS部分答案解析
web for pentester是国外安全研究者开发的的一款渗透测试平台,通过该平台你可以了解到常见的Web漏洞检测技术. 下载链接及文档说明: http://pentesterlab.com/ex ...
- 不用派生CTreeCtrl不用繁琐的过程 教你如何让CTreeCtrl的每一项有ToolTip提示
最近工作中需要让CTreeCtrl控件的每一项都有提示信息,于是谷歌百度,爬山涉水,结果是………….在CodeProject里找到一篇文章是把CTreeCtrl派生出新类,重载一些函数自定义内容.使用 ...
- 转:创建编码的WebTest
创建编码的WebTest•通常,通过将现有的已记录Web测试转换为编码的Web测试来创建编码的Web测试.记录的Web测试以“Web测试编辑器”中可见的请求树开头.编码的Web测试是一个生成一系列We ...
- office web apps部署(二)
1.安装composer 参考 http://docs.phpcomposer.com/00-intro.md 根据系统选择安装方式 修改php.ini 去掉extension=php_opens ...
- OpenCV——轮廓特征描述
检测出特定轮廓,可进一步对其特征进行描述,从而识别物体. 1. 如下函数,可以将轮廓以多种形式包围起来. // 轮廓表示为一个矩形 Rect r = boundingRect(Mat(contours ...
随机推荐
- iOS UITableView划动删除的实现
标签:划动删除 iphone 滑动删除 ios UITableView 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://rainb ...
- IntelliJ中的main函数和System.out.println()快捷输入方式
转自:https://blog.csdn.net/assassinsshadow/article/details/73557375 main快捷输入 psvm System.out.println() ...
- [Algorithms] Sorting Algorithms (Insertion Sort, Bubble Sort, Merge Sort and Quicksort)
Recently I systematicall review some sorting algorithms, including insertion sort, bubble sort, merg ...
- Java版斯诺克开源分享
Java版斯诺克开源分享 这个小程序是我平时无聊写着玩的,在网盘里躺了好久了,今天就把它拿出来跟大家分享一下,下面是游戏截图: 请不要吐槽这个界面,斯诺克的球台是我从qq游戏里面截取的... 下面是源 ...
- python中,有关正则表达式re函数:compile、match、search、findall
1.全局匹配函数 re.compile(pattern=pattern,re.S).findall(text)函数: compile 函数根据一个模式字符串和可选的标志参数生成一个正则表达式对象.该对 ...
- Learning PHP Design Patterns
Learning PHP Design Patterns CHAPTER 1 Algorithms handle speed of operations, and design patterns ha ...
- Vulnerabilities by Type
w http://hackergossips.com/cross-site-scriptingxss-and-preventing/
- jquery根据值设置radio和select选中状态
1.radio选中: $("input[name=test][value=34]").attr("checked",true);//value=34的radio ...
- 阻塞IO 非阻塞IO 异步IO
阻塞IO 一般表现为 进程/线程 调用IO操作后就一直死循环等待,直至IO操作结束,返回IO结果 非阻塞IO 一般表现为 进程/线程 调用IO操作后,可以先去干别的事情,但是每隔一段时间,回去询问一下 ...
- windows下使用IIS创建git服务
Bonobo Git Server 下载地址: https://bonobogitserver.com/ 安装方法:https://bonobogitserver.com/install/ 配置简单, ...