我正在使用sidekiq
在制作方面,我每天要处理大约100个工作岗位,排队等候2000个工作岗位。
我发现大多数时候由于SMTP连接导致作业失败。
我遇到的与sidekiq失败的错误是
ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
Processor: mysite:17289
Net::SMTPAuthenticationError: 435 Unable to authenticate at present
Processor: mysite:17289
但是大多数作业都在相同的SMTP连接中成功处理。
此外,我已将重试条件设置为
sidekiq_options retry: 5
sidekiq_retry_in do |count|
10 * (count + 1) # (i.e. 10, 20, 30, 40)
end
可能是什么原因?谁能猜?
提前致谢
修改
这是我的AdvertisementWorker
class AdvertisementWorker
include Sidekiq::Worker
#sidekiq_options queue: "high"
sidekiq_options retry: 5
sidekiq_retry_in do |count|
10 * (count + 1) # (i.e. 10, 20, 30, 40)
end
def perform(advertisement_id)
advertisement = Advertisement.find_by_id(advertisement_id)
cost = advertisement.is_reactivation_chargable? ? advertisement.ad_type.value : ZERO_COST
timezone = advertisement.user.timezone.nil? ? DEFAULT_TIMEZONE : advertisement.user.timezone
schedule_time_def = advertisement.expire_at.nil? ? 0 : ((advertisement.expire_at.in_time_zone(timezone) - Time.now.in_time_zone(timezone))/1.hour).round
unless schedule_time_def >= 6
advertisement.expire!
UserMailer.send_ad_expired_email(advertisement).deliver if advertisement.is_ad_expiry_notifiable?
if advertisement.can_auto_renew?
if advertisement.reactivate!
advertisement.remove_token_charge(cost) if cost.to_i > 0
UserMailer.send_seller_ad_reposted_email(advertisement).deliver if advertisement.is_ad_renew_notifiable?
advertisement.schedule_sidekiq_job
end
end
end
end
end
修改
这是sidekiq日志
2014-05-19T05:14:26Z 20682 TID-9z4kc Sidekiq::Extensions::DelayedMailer JID-8e5eeba2afd077ccbca10646 INFO: start
2014-05-19T05:14:26Z 20682 TID-9z4kc Sidekiq::Extensions::DelayedMailer JID-8e5eeba2afd077ccbca10646 INFO: fail: 0.012 sec
2014-05-19T05:14:26Z 20682 TID-9z4kc WARN: {"retry"=>true, "queue"=>"default", "class"=>"Sidekiq::Extensions::DelayedMailer", "args"=>["---\n- !ruby/class 'UserMailer'\n- :send_seller_ad_reposted_email\n- - !ruby/object:Advertisement\n attributes:\n id: 1781\n user_id: 99\n status: A\n custom_id: \n title: Possible Male Crested Gecko Cn37\n details: |\n <p>*Red and Yellow Harlequin!* Approximate hatch: 10/2013</p>\n\n <p>Possible Male (some visible pores)</p>\n\n <p>Weight: 8 grams</p>\n\n <p> </p>\n\n <p><a href=\"http://www.pangeareptile.com/store/new-possible-male-crested-gecko-0417-cn37.html\"><span style=\"font-size:20px\"><strong>PURCHASE HERE</strong></span></a></p>\n keywords: Red Yellow Crested Gecko for sale Pangea\n published_at: \n ad_duration: 30\n is_renewed: true\n renewed_till: \n is_ad_expired_notification: false\n category_id: 141\n sex: unknown\n weight: \n is_bin: false\n paypal_account: \n total_quantity: 0\n remaining_quantity: 0\n is_multiple_buy: false\n item_price: 0.0\n shipping_handling_price: 0.0\n comment: \n blocked: \n ad_signature: \n created_at: 2014-04-18 18:59:18.712041000 Z\n updated_at: 2014-05-19 04:49:56.682501024 Z\n ad_type: \n will_trade: false\n no_bin_price_type: ''\n no_bin_price: 299.99\n publish_time: \n ad_type_id: 3\n activation_date: 2014-05-19 04:49:56.680462283 Z\n views: 1\n expire_at: 2014-06-18 04:49:56.680462283 Z\n renewed_times: 1\n renewed_at: 2014-05-19 04:49:56.680514387 Z\n sold: 0\n upgrade_type_id: 3\n expire_mail_sent: false\n check_signature: \n scheduled_admin: false\n hold: 0\n job_id: 3083e6f7d252cbe309c0709f\n"], "jid"=>"8e5eeba2afd077ccbca10646", "enqueued_at"=>1400474996.731637, "error_message"=>"An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.", "error_class"=>"ArgumentError", "failed_at"=>1400476466.3814178, "retry_count"=>6, "retried_at"=>1400476466.381097, "processor"=>"marketplace.thereptilereport.com:20682"}
2014-05-19T05:14:26Z 20682 TID-9z4kc WARN: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
2014-05-19T05:14:26Z 20682 TID-9z4kc WARN: /var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/check_delivery_params.rb:9:in `check_delivery_params'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:98:in `deliver!'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:456:in `block in deliver_mail'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159:in `block in instrument'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159:in `instrument'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:454:in `deliver_mail'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/extensions/action_mailer.rb:20:in `perform'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:50:in `block (2 levels) in process'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:122:in `call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/retry_jobs.rb:62:in `call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-failures-0.4.1/lib/sidekiq/failures/middleware.rb:9:in `call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/logging.rb:22:in `with_context'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:127:in `call'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:127:in `invoke'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:49:in `block in process'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:92:in `stats'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:48:in `process'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
/var/www/trrm_prod/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
答案 0 :(得分:2)
发布您的实际代码。您的代码中可能存在线程安全问题。