Pergunta

ActiveRecord::RecordNotFound: Couldn't find User with id=42606 [WHERE ("users".deleted_at IS NULL)]

devise_async.rb:

Devise::Async.backend = :sidekiq
Devise::Async.queue = :mailer

sidekiq.rb:

if Rails.env.production?
  Sidekiq.configure_server do |config|
    config.redis = { url: 'redis://production-redis.xxxxxx.0001.usw2.cache.amazonaws.com', :namespace => 'sidekiq_prod' }
  end

  Sidekiq.configure_client do |config|
    config.redis = { url: 'redis://production-redis.xxxxxx.0001.usw2.cache.amazonaws.com', :namespace => 'sidekiq_prod' }
  end

I have other workers sending things to segment.io that are working, but devise isn't sending my welcome emails or password reset emails because it can't find the users. I'm thinking it's connecting to the wrong database but I'm not sure.

I'd appreciate anything to point me in the right direction as to why it cant find my users.

Foi útil?

Solução

I'm also struggling with this sporadic issue since many months. Actually i also had this already with resque.

My lucky guess is: the job gets triggered as the user registers and the user model is just saved. But the Sidekiq job already tries to load the user, which should be in the database, but maybe the db-transaction where the user.save happened, doesn't seem to be commited yet.

So when i try to reproduce this issue, there IS an user with the given id, and maybe thats why you don't have any timestamp set in deleted_at.

I will try to run the welcome-mailer with a slight delay of 5-10sec and check if this still happens.

Kind regards

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top