RDS 在线DDL诡异报错ERROR 1062 (23000): Duplicate entry
来源:互联网 发布:淘宝手机详情添加链接 编辑:程序博客网 时间:2024/06/06 20:25
RDS上执行报错如下:
MySQL [ad_billing]> ALTER TABLE ad_spending ADD COLUMN impr bigint(20) NOT NULL DEFAULT 0 COMMENT '曝光数' after `mall_id`;ERROR 1062 (23000): Duplicate entry '2017-08-04-3-936158' for key 'scene_date_ad'MySQL [ad_billing]>
可以确定不会有重复数据,因为scene_date_ad是唯一约束字段,再次验证不是数据的问题,因为没有重复记录
MySQL [ad_billing]> select date,scene_id,ad_id,count(1) from ad_spending group by date,scene_id,ad_id having(count(1)>1) -> ;Empty set (0.43 sec)
google资料,看到如下信息:
When running an online DDL operation, the thread that runs the ALTER TABLE statement applies an “online log” of DML operations that were run concurrently on the same table from other connection threads. When the DML operations are applied, it is possible to encounter a duplicate key entry error (ERROR 1062 (23000): Duplicate entry), even if the duplicate entry is only temporary and would be reverted by a later entry in the “online log”. This is similar to the idea of a foreign key constraint check in InnoDB in which constraints must hold during a transaction.
“`
这是RDS实例的bug,再结合到这个表之前做过几百万行的delete from table where pkid=xxxxx;的操作,所以导致碎片化比较严重,加上这个表的业务也在实时操作,所以导致线上alter操作异常触发雷区。
然后rds官方技术支持,建议使用pt-online-schema-change去执行alter操作,参考rds如何使用pt组件:https://help.aliyun.com/knowledge_detail/41734.html
- RDS 在线DDL诡异报错ERROR 1062 (23000): Duplicate entry
- 报错 1062:Duplicate entry '4294967295' for key 'PRIMARY'
- ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
- ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'
- MySQL ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
- ERROR 1062 (23000): Duplicate entry '5' for key 'PRIMARY'
- AndroidStudio打包报错:duplicate entry
- ERROR 1062 (23000) at line 26903: Duplicate entry 'onli????' for key 'xxxx_script_name'
- txt导入Mysql:ERROR 1062(23000):Duplicate entry '0' for key 'PRIMARY'
- MySql出现ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
- ERROR 1062 (23000) at line 1: Duplicate entry '1332883220' for key 'group_key'
- ERROR 1062 (23000): ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1'
- mysql数据库:ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'
- 经典的MySQL Duplicate entry报错注入
- mysql报错:Duplicate entry ‘1’ for key ‘PRIMARY’
- 【报错】Duplicate entry '0' for key 'PRIMARY'
- androidstuido报错之Java.util.zip.ZipException: duplicate entry
- MySQL --- SQL Error: 1062: Duplicate entry '2147483647' for key 'PRIMARY'
- CodeForces 427D-Match & Catch
- MFC—4个基本类中的成员函数介绍
- Python::两种格式化输出方式
- iOS MesaSQLite数据库简单使用
- MFC中AfxMessageBox和MessageBox的区别
- RDS 在线DDL诡异报错ERROR 1062 (23000): Duplicate entry
- 最小生成生成树计数
- MySQL
- hdu6087 dp
- BZOJ 2440 完全平方数 (莫比乌斯函数 容斥)
- DeepLearning&Tensorflow学习笔记2__mnist数据集CNN
- ios面试题,各大企业常见的ios面试题之二
- leapjs学习
- MFC中CDC的使用