简体   繁体   English

Sidekiq 作业不断出现在 Rails 应用程序中

[英]Sidekiq Job Keeps Reappearing in Rails App

I have a Sidekiq job that keeps resurrecting from the dead - even after deleting the job in the Sidekiq Web UI it still manages to re-run.我有一个 Sidekiq 作业,它不断从死里复活 - 即使在 Sidekiq Web UI 中删除作业后,它仍然设法重新运行。 This has been going on for over two months now, and after deleting the job, when I boot up the Rails app it will send.这已经持续了两个多月,在删除作业后,当我启动 Rails 应用程序时,它会发送。

Sidekiq 用户界面

The job is part of an Invitation System, wherein the inviter gets an email notification when someone accepts the invite.该工作是邀请系统的一部分,当有人接受邀请时,邀请者会收到电子邮件通知。 I've never had 37 Member records so it's unclear how it's looking for ID 37, and it's unclear how the job keeps on running.我从来没有 37 个成员记录,所以不清楚它是如何寻找 ID 37 的,也不清楚这项工作如何继续运行。 Any idea?任何的想法?

Console Log控制台日志

16:03:42 web.1           | [19555] - Worker 0 (pid: 20745) booted, phase: 0
16:03:42 sidekiq.1       |   FacilityMember Load (1.4ms)  SELECT "members".* FROM "members" WHERE "members"."type" = $1 AND "members"."id" = $2 LIMIT $3  [["type", "FacilityMember"], ["id", 37], ["LIMIT", 1]]
16:03:42 sidekiq.1       | 2019-12-26T21:03:42.760Z pid=19576 tid=ovbl501oc class=ActionMailer::MailDeliveryJob jid=d991b5a607693bfc5e78305f elapsed=1.735 INFO: fail
16:03:42 sidekiq.1       | 2019-12-26T21:03:42.760Z pid=19576 tid=ovbl501oc WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ActionMailer::MailDeliveryJob","queue":"mailers","args":[{"job_class":"ActionMailer::MailDeliveryJob","job_id":"84b9126d-0319-44c6-a6cc-df790d577e7d","provider_job_id":null,"queue_name":"mailers","priority":null,"arguments":["InviteMailer","facility_invite_accepted","deliver_now",{"args":[{"_aj_globalid":"gid://openunit/FacilityMember/37"}],"_aj_symbol_keys":["args"]}],"executions":0,"exception_executions":{},"locale":"en","timezone":"UTC","enqueued_at":"2019-10-13T00:49:50Z"}],"retry":true,"jid":"d991b5a607693bfc5e78305f","created_at":1570927790.259349,"enqueued_at":1577394221.019845,"error_message":"Error while trying to deserialize arguments: Couldn't find FacilityMember with 'id'=37 [WHERE \"members\".\"type\" = $1]","error_class":"ActiveJob::DeserializationError","failed_at":1570927790.303255,"retry_count":8,"retried_at":1577389107.42818},"jobstr":"{\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"ActionMailer::MailDeliveryJob\",\"queue\":\"mailers\",\"args\":[{\"job_class\":\"ActionMailer::MailDeliveryJob\",\"job_id\":\"84b9126d-0319-44c6-a6cc-df790d577e7d\",\"provider_job_id\":null,\"queue_name\":\"mailers\",\"priority\":null,\"arguments\":[\"InviteMailer\",\"facility_invite_accepted\",\"deliver_now\",{\"args\":[{\"_aj_globalid\":\"gid://openunit/FacilityMember/37\"}],\"_aj_symbol_keys\":[\"args\"]}],\"executions\":0,\"exception_executions\":{},\"locale\":\"en\",\"timezone\":\"UTC\",\"enqueued_at\":\"2019-10-13T00:49:50Z\"}],\"retry\":true,\"jid\":\"d991b5a607693bfc5e78305f\",\"created_at\":1570927790.259349,\"enqueued_at\":1577394221.019845,\"error_message\":\"Error while trying to deserialize arguments: Couldn't find FacilityMember with 'id'=37 [WHERE \\\"members\\\".\\\"type\\\" = $1]\",\"error_class\":\"ActiveJob::DeserializationError\",\"failed_at\":1570927790.303255,\"retry_count\":8,\"retried_at\":1577389107.42818}"}
16:03:42 sidekiq.1       | 2019-12-26T21:03:42.760Z pid=19576 tid=ovbl501oc WARN: ActiveJob::DeserializationError: Error while trying to deserialize arguments: Couldn't find FacilityMember with 'id'=37 [WHERE "members"."type" = $1]

Sidekiq.rb Sidekiq.rb

# frozen_string_literal: true

require 'sidekiq/testing/inline'

RSpec.configure do |config|
  config.after(:each, :sidekiq) do
    Sidekiq::Worker.clear_all
  end

  config.after(:each, :sidekiq, :redis) do
    Sidekiq.redis do |connection|
      connection.redis.flushdb
    end
  end
end

If that is indeed config/initializers/sidekiq.rb then your Sidekiq is configured for testing.如果那确实是config/initializers/sidekiq.rb则您的 Sidekiq 已配置用于测试。

Specifically require 'sidekiq/testing/inline' puts it in inline test mode which causes Sidekiq to execute jobs immediately.特别require 'sidekiq/testing/inline'将其置于内联测试模式,这会导致 Sidekiq 立即执行作业。 And the rest of your configuration is for the RSpec testing framework.其余配置用于RSpec测试框架。

This should be instead in an isolated test directory such as spec/support/config/ .这应该在一个独立的测试目录中,例如spec/support/config/ Load it with something like this in spec/rails_helper.rb .spec/rails_helper.rb使用类似的内容加载它。

Rails.root.join('spec/support/').glob('**/*.rb') { |f| require f }

See Clean RSpec configuration directory structure for Ruby on Rails gems needed in testing .请参阅Clean RSpec configuration directory structure for Ruby on Rails gems needed in testing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM