Skip to content

Instantly share code, notes, and snippets.

@igorkasyanchuk
Last active September 9, 2016 07:12
Show Gist options
  • Save igorkasyanchuk/cc96dba31b0b0f83b77faadf077433e8 to your computer and use it in GitHub Desktop.
Save igorkasyanchuk/cc96dba31b0b0f83b77faadf077433e8 to your computer and use it in GitHub Desktop.
class RedZoneCrossedWorker < Worker
def perform(event_id)
Chewy.strategy(:atomic) do
puts "#{self.class.name} Performing: #{event_id} #{jid}"
event = RedZoneCrossedShipmentEvent.find_by(id: event_id)
shipment = event.try(:shipment)
if shipment
# generate driver/oo payments
shipment.generate_red_zone_payments
# send mails and notifications if red zone crossed successfully
notifier = event.successfully_completed? ? 'ShipmentNotifiers::ShipmentRedZoneSuccessNotifier' : 'ShipmentNotifiers::ShipmentRedZoneViolationsNotifier'
ShipmentNotificationWorker.new.perform(event.shipment_id, notifier)
end
end
end
end
Message
PG::UnableToSend: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
Traceback
PG::UnableToSend: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 215, in exec
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 215, in dealloc
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 198, in block in clear
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 197, in each_value
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 197, in clear
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 258, in clear_cache!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb", line 291, in reconnect!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 275, in reconnect!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb", line 328, in verify!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 456, in block in checkout_and_verify
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb", line 88, in __run_callbacks__
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb", line 778, in _run_checkout_callbacks
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 455, in checkout_and_verify
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 351, in block in checkout
File "/usr/local/rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb", line 211, in mon_synchronize
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 348, in checkout
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 263, in block in connection
File "/usr/local/rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb", line 211, in mon_synchronize
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 262, in connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 571, in retrieve_connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb", line 113, in retrieve_connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb", line 87, in connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/core.rb", line 187, in find_by
File "/opt/app-backend/releases/20160908092731/app/workers/red_zone_crossed_worker.rb", line 5, in block in perform
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/chewy-0.8.4/lib/chewy/strategy.rb", line 60, in wrap
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/chewy-0.8.4/lib/chewy.rb", line 179, in strategy
File "/opt/app-backend/releases/20160908092731/app/workers/red_zone_crossed_worker.rb", line 3, in perform
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 152, in execute_job
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 134, in block (2 levels) in process
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 128, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/rollbar-2.11.5/lib/rollbar/plugins/sidekiq/plugin.rb", line 9, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/instrumentation/sidekiq.rb", line 33, in block in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/instrumentation/controller_instrumentation.rb", line 362, in perform_action_with_newrelic_trace
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/instrumentation/sidekiq.rb", line 29, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-pg_helpers-0.2.0/lib/sidekiq/pg_helpers/middleware/connection_recovery.rb", line 16, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/active_record.rb", line 6, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/retry_jobs.rb", line 74, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/logging.rb", line 11, in block in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/logging.rb", line 32, in with_context
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/logging.rb", line 7, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 133, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 133, in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 129, in block in process
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 168, in stats
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 128, in process
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 80, in process_one
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 68, in run
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/util.rb", line 17, in watchdog
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/util.rb", line 25, in block in safe_thread
PG::UnableToSend: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 215, in exec
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 215, in dealloc
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 198, in block in clear
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 197, in each_value
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 197, in clear
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 258, in clear_cache!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb", line 291, in reconnect!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb", line 275, in reconnect!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb", line 328, in verify!
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 456, in block in checkout_and_verify
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb", line 88, in __run_callbacks__
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb", line 778, in _run_checkout_callbacks
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 455, in checkout_and_verify
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 351, in block in checkout
File "/usr/local/rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb", line 211, in mon_synchronize
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 348, in checkout
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 263, in block in connection
File "/usr/local/rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb", line 211, in mon_synchronize
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 262, in connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb", line 571, in retrieve_connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb", line 113, in retrieve_connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb", line 87, in connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-pg_helpers-0.2.0/lib/sidekiq/pg_helpers/middleware/connection_recovery.rb", line 38, in clean_up_connection
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-pg_helpers-0.2.0/lib/sidekiq/pg_helpers/middleware/connection_recovery.rb", line 18, in rescue in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-pg_helpers-0.2.0/lib/sidekiq/pg_helpers/middleware/connection_recovery.rb", line 16, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/active_record.rb", line 6, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/retry_jobs.rb", line 74, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/logging.rb", line 11, in block in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/logging.rb", line 32, in with_context
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/server/logging.rb", line 7, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 130, in block in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 133, in call
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/middleware/chain.rb", line 133, in invoke
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 129, in block in process
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 168, in stats
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 128, in process
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 80, in process_one
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/processor.rb", line 68, in run
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/util.rb", line 17, in watchdog
File "/opt/app-backend/shared/bundle/ruby/2.2.0/gems/sidekiq-4.1.3/lib/sidekiq/util.rb", line 25, in block in safe_thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment