Rails on Heroku, Unicorn and Delayed Job: PG::ConnectionBadappmodels/post.rb:93 PQconsumeInput() SSL SYSCALL error: Connection timed out

goddamnyouryan

I'm running a Rails 4.1.9 (Ruby 2.2.0) on heroku with unicorn and using delayed jobs to process stuff in the background. At any given moment I've got about 8 workers running.

Occasionally I'll see the following error in my logs:

PG::ConnectionBad
PQconsumeInput() SSL SYSCALL error: Connection timed out
app/models/post.rb:93 build

These errors are always coming from some background jobs I am running.

As far as I understand it, Delayed Jobs does not actually use unicorn to run workers, it's just a single worker process per worker dyno. Yet all the issues I see around this seem to stem from unicorn.

My unicorn.rb file looks like:

worker_processes 3
timeout 30
preload_app true
listen ENV['PORT'], backlog: Integer(ENV['UNICORN_BACKLOG'] || 200)

before_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

I googled around and came across the following links:

The first link tells me to add My config files to unicorn, the second tells me to change my DB_REAPING_FREQUENCY, and the third one tells me to upgrade my DB (I have the $50 a month DB already)

Any idea about what might be going wrong here and where to start fixing it? I'm not even sure where to look.

goddamnyouryan

This ended up actually just being a job that took FOREVER (like 4 minutes) to run, due to some inefficient querying on my end.

Took me a remarkably long time to figure out which jobs, for such a simple and dumb solution.

I just waited until I saw that the number of jobs wasn't decreasing, ran this code:

dj = Delayed::Job.where('run_at is not null').sample

then got the handler with dj.handler to see what the actual method that was being called was, on what object, then just ran it myself and saw that it was really slow, and fixed it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails on Heroku, Unicorn and Delayed Job: PG::ConnectionBadappmodels/post.rb:93 PQconsumeInput() SSL SYSCALL error: Connection timed out

From Dev

Heroku + Rails + PG: ActiveRecord::StatementInvalid (PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly

From Dev

Receiving "ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out" in rake task

From Dev

Connection timed out error

From Dev

Connection Timed out in Installing rails

From Dev

Error with timed out bluetooth connection

From Dev

Error 522: Connection timed out

From Dev

ssh error: connection timed out

From Dev

MailEnable error connection timed out

From Dev

flash error from delayed job in rails

From Dev

android studio error Error:Connection timed out

From Dev

CNUI ERROR Contact view delayed appearance timed out

From Dev

pg.InternalError: SSL SYSCALL error: EOF detected

From Dev

Connection timed out error in intellij Idea

From Dev

TinyTds Error: Adaptive Server connection timed out

From Dev

PuTTY returns Network error: Connection timed out

From Dev

Mongodb is throwing "connection timed out" error

From Dev

Apache Flink InvocationTargetException: Job execution failed. Connection timed out

From Dev

Apache Flink InvocationTargetException: Job execution failed. Connection timed out

From Dev

How to protect against Redis::TimeoutError: Connection timed out on Heroku

From Dev

Delayed Job - Rails 4

From Dev

Nginx upstream timed out for long unicorn request

From Dev

Bizarre PG::UndefinedTable Error with Rails app on Heroku

From Dev

PG::UndefinedTable ERROR ruby on rails heroku

From Java

Https connection, TLS hangs and eventually fails SSL_ERROR_SYSCALL

From Dev

Heroku delayed_job dependencies

From Dev

Delayed Job on Heroku does not work

From Dev

pooled connection timed out

From Dev

PHPMailer connection timed out

Related Related

  1. 1

    Rails on Heroku, Unicorn and Delayed Job: PG::ConnectionBadappmodels/post.rb:93 PQconsumeInput() SSL SYSCALL error: Connection timed out

  2. 2

    Heroku + Rails + PG: ActiveRecord::StatementInvalid (PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly

  3. 3

    Receiving "ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out" in rake task

  4. 4

    Connection timed out error

  5. 5

    Connection Timed out in Installing rails

  6. 6

    Error with timed out bluetooth connection

  7. 7

    Error 522: Connection timed out

  8. 8

    ssh error: connection timed out

  9. 9

    MailEnable error connection timed out

  10. 10

    flash error from delayed job in rails

  11. 11

    android studio error Error:Connection timed out

  12. 12

    CNUI ERROR Contact view delayed appearance timed out

  13. 13

    pg.InternalError: SSL SYSCALL error: EOF detected

  14. 14

    Connection timed out error in intellij Idea

  15. 15

    TinyTds Error: Adaptive Server connection timed out

  16. 16

    PuTTY returns Network error: Connection timed out

  17. 17

    Mongodb is throwing "connection timed out" error

  18. 18

    Apache Flink InvocationTargetException: Job execution failed. Connection timed out

  19. 19

    Apache Flink InvocationTargetException: Job execution failed. Connection timed out

  20. 20

    How to protect against Redis::TimeoutError: Connection timed out on Heroku

  21. 21

    Delayed Job - Rails 4

  22. 22

    Nginx upstream timed out for long unicorn request

  23. 23

    Bizarre PG::UndefinedTable Error with Rails app on Heroku

  24. 24

    PG::UndefinedTable ERROR ruby on rails heroku

  25. 25

    Https connection, TLS hangs and eventually fails SSL_ERROR_SYSCALL

  26. 26

    Heroku delayed_job dependencies

  27. 27

    Delayed Job on Heroku does not work

  28. 28

    pooled connection timed out

  29. 29

    PHPMailer connection timed out

HotTag

Archive