【问题标题】:Activejob fails deserializing an objectActivejob 反序列化对象失败
【发布时间】:2015-02-17 12:28:32
【问题描述】:

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

这是我看到的:

{"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),但没有任何区别。

知道发生了什么吗?

谢谢。

【问题讨论】:

    标签: ruby-on-rails sidekiq rails-activejob


    【解决方案1】:

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

    【讨论】:

    • @mike_perham 请阅读我的问题。我已经试过了(虽然使用 Mongoid):mongoid.org/en/mongoid/docs/callbacks.html
    • 请阅读我的评论。 :-) after_commit 不是 after_create。
    • 我知道,但是 Mongoid 没有那个回调(after_commit)。
    • 这是不正确的。这与 Sidekiq 的速度无关。之所以会这样,是因为 after_commit 在事务完成后触发
    • Sidekiq 的速度让比赛状况更加明显。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-26
      • 2012-06-20
      • 1970-01-01
      • 2017-02-11
      • 2011-06-14
      • 2020-08-12
      • 2019-08-12
      相关资源
      最近更新 更多