我在rails后端构建ruby以支持ios和android应用程序。一段代码应该处理通过推送通知推送的聊天消息。由于某些原因,这些查询运行
[2014-03-05 09:36:38.242] [DEBUG] ^[[1m^[[35mRpush::Notification Load (2.5ms)^[[0m SELECT "rpush_notifications".* FROM "rpush_notifications" WHERE (delivered = 'f' AND failed = 'f' AND (deliver_after IS NULL OR deliver_after < '2014-03-05 14:36:38.238624')) AND (app_id IN (1,2)) (pid:7523)
[2014-03-05 09:36:41.410] [DEBUG] ^[[1m^[[36mSQL (41.7ms)^[[0m ^[[1mUPDATE "rpush_notifications" SET delivered = 't', delivered_at = '2014-03-05 14:36:41.258814' WHERE "rpush_notifications"."id" IN (187, 188)^[[0m (pid:7523)
我的表中的结果看起来像
id | delivered | delivered_at | failed | failed_at
-----+-----------+----------------------------+--------+----------------------------
188 | f | | f |
187 | t | 2014-03-05 14:36:41.258814 | f |
186 | t | 2014-03-05 14:33:55.845077 | f |
注意id为188的第一行没有更新,而id为187,并且那里的时间戳与查询匹配。任何人都知道为什么会这样吗?
修改 发现代码中存在行锁定条件并将其修复
答案 0 :(得分:0)
发现代码中存在行锁定条件,并在删除时修复了问题。