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的更多相关文章

  1. ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'

    OS: centos 6.3DB: 5.5.14 测试创建yoon测试表,没有主键,没有索引,基础数据内容如下: mysql> select * from yoon;+----+-------- ...

  2. ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'

    use mysql mysql> select host, user from user; 将相应用户数据表中的host字段改成'%': update user set host='%' whe ...

  3. ERROR 1062 (23000): Duplicate entry for key 'PRIMARY'

    ALTER TABLE table1 ADD COLUMN column1 VARCHAR(400) DEFAULT NULL; ERROR 1062 (23000): Duplicate entry ...

  4. ERROR 1062 (23000): Duplicate entry '1-1' for key 'PRIMARY'

    这个错误是说,由于某个SQL操作造成了,表中主键重复. 例子: create table t(x int,y int,z int, primary key(x,y)); insert into t(x ...

  5. mysql创建唯一索引UNIQUE INDEX,以及报错“#失败原因: [Execute: Duplicate entry '733186700' for key 'uniq_video_id_index']”

    要给t_video_prods表的video_id字段创建唯一所以,可以使用下面这条语句: alter table t_video_prods add UNIQUE INDEX `uniq_video ...

  6. sqlalchemy.exc.IntegrityError: (mysql.connector.errors.IntegrityError) 1062 (23000): Duplicate entry '1' for key 'PRIMARY'

    排错: 看到 Duplicate entry '1' for key 'PRIMARY'是主键错误 看一看自己添加的数据id是1 再查询一下数据库中的表,发现id=1的记录已经存在了 所以在代码中让i ...

  7. linux使用wkhtmltopdf报错error while loading shared libraries:

    官网提示 linux需要这些动态库.depends on: zlib, fontconfig, freetype, X11 libs (libX11, libXext, libXrender) 在li ...

  8. 发布报错:Error ITMS-90635 - Invalid Mach-O in bundle - submitting to App store

    发布报错:Error ITMS-90635 - Invalid Mach-O in bundle - submitting to App store 昨晚上传项目到AppStore,报了这个错,纳尼! ...

  9. 升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    系统升级到macOS 10.12后启动mysql后,在终端输入mysql 报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' ...

随机推荐

  1. 20162314 Sortingtest-work after class

    20162314 Sortingtest-work after class Content Data : 90 8 7 56 123 235 9 1 653. Use JDB or IDEA to t ...

  2. C teaching

    L1 Preparation 1. environment codeblocks 2.variable, const 3. data type int "%d" char &quo ...

  3. linux信号的介绍

    1.基本概念    中断:        中断是系统对于异步事件的响应        中断信号        中断源        现场信息        中断处理程序        中断向量表   ...

  4. windows 下获取父进程pid

    DWORD GetParentProcessID(DWORD dwProcessId) { LONG status; DWORD dwParentPID = (DWORD)-1; HANDLE hPr ...

  5. Hive的Explain命令

    Hive的Explain命令,用于显示SQL查询的执行计划. Hive查询被转化成序列阶段(这是一个有向无环图).这些阶段可能是mapper/reducer阶段,或者是Metastore或文件系统的操 ...

  6. mysql_fetch_assoc查询多行数据

    每次从查询结果中返回一行数据,作为关联数组,类似于一个游标,第一次是返回第一行,第二次迭代就是第二行,以此类推 如果返回多行,使用如下方法就可以了 while($row = $db->fetch ...

  7. 修改windows命令行字体

    YaHei Consolas Hybrid

  8. bootstrap自定义——栅格列数修改

    从下载的bootstrap文件中找到less文件夹里面的variables.less,然后可以找到栅格列数进行修改 然后执行一下bootstrap.less,通过命令行,切换到其所在的目录D:\03 ...

  9. 阿里云centOS7.4 ftp连接不上的问题

    首先查看是开启21端口 选择ECS-->安全组-->配置规则 增加21端口配置 配置如下

  10. FTRL 使用tensorflow的实现

    import tensorflow as tfimport numpy as npfrom sklearn import metricsfrom sklearn.datasets import loa ...