Rub*_*con 7 mysql mysql-5.6 rails
我有以下 MySQL RoR 迁移:
class ReindexRpushNotification < ActiveRecord::Migration
def up
execute("DROP INDEX `index_rpush_notifications_multi` ON rpush_notifications;")
execute("ALTER TABLE rpush_notifications ADD INDEX index_rpush_notifications_multi (delivered, failed, processing, deliver_after), ALGORITHM=INPLACE, LOCK=NONE;")
end
def down
execute("DROP INDEX `index_rpush_notifications_multi` ON rpush_notifications;")
execute("ALTER TABLE rpush_notifications ADD INDEX index_rpush_notifications_multi (delivered, failed), ALGORITHM=INPLACE, LOCK=NONE;")
end
end
Run Code Online (Sandbox Code Playgroud)
在这次迁移期间,我正在尝试执行一些请求(GET、COUNT、DELETE、UPDATE)但没有任何效果,所有这些请求都在等待
我在这里找到了有关在后台创建索引的信息
http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html
但它对我们不起作用
有人试过LOCK=NONE吗?
我们在 AWS RDS 上使用 MySQL 5.6.23
Rub*_*con 12
看起来我知道为什么它不起作用
我们的表有以下约束:
CONSTRAINT `rpush_notifications_event_id_fk`
FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
Run Code Online (Sandbox Code Playgroud)
接下来,我在这里发现了一件有趣的事情:https : //blogs.oracle.com/mysqlinnodb/entry/online_alter_table_in_mysql
以下情况不允许在线操作(LOCK=NONE):
- 添加 AUTO_INCREMENT 列时,
- 当表包含 FULLTEXT 索引或隐藏的 FTS_DOC_ID 列时,或
- 当存在引用表的 FOREIGN KEY 约束时,使用 ON...CASCADE 或 ON...SET NULL 选项。
所以看起来我们有第三个案例
归档时间: |
|
查看次数: |
11872 次 |
最近记录: |