Activejob 反序列化对象失败

Activejob fails deserializing an object

为了测试我的邮件是否正在发送,我 运行 heroku run rails c -a my_app。然后我将工作排入队列并且排入队列很好。但是,当我去 Redis 并查看排队的作业时,该作业不存在。相反,它位于 "retry"。

这是我看到的:

{"retry":true,"queue":"default","class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","args":[{"job_class":"SendMailJob","job_id":"4b4ba46f-94d7-45cd-b923-ec1678c73076","queue_name":"default","arguments":["any_help",{"_aj_globalid":"gid://gemfeedapi/User/546641393834330002000000"}]}],"jid":"f89235d7ab19f605ed0461a1","enqueued_at":1424175756.9351726,"error_message":"Error while trying to deserialize arguments: \nProblem:\n Document(s) not found for class User with id(s) 546641393834330002000000.\nSummary:\n When calling User.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 546641393834330002000000 ... (1 total) and the following ids were not found: 546641393834330002000000.\nResolution:\n Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.","error_class":"ActiveJob::DeserializationError","failed_at":1424175773.317896,"retry_count":0}

但是,对象在数据库中。

我尝试添加 after_create 回调 (Mongoid) 但没有任何区别。

知道发生了什么吗?

谢谢。

Sidekiq 的速度如此之快,以至于它在数据库提交事务之前就执行了您的作业。使用 after_commit 创建作业。

好吧,我的错。您需要启动一个新的 Heroku Worker Dyno 才能使 Sidekiq 工作(它不会自动执行)。