PG::UnableToSend: no connection to the server #628

Closed
fullofcaffeine opened this Issue Feb 17, 2014 · 2 comments

Projects

None yet

3 participants

@fullofcaffeine

When I try to run delayed_job in the foreground, using:

$ RAILS_ENV=development script/delayed_job run

I get:

✗ RAILS_ENV=development script/delayed_job run
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
delayed_job: process with pid 56692 started.
PG::UnableToSend: no connection to the server
: UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:myhost pid:56692')

The error happens in the delayed_job_activerecord backend, in this method:

     # When a worker is exiting, make sure we don't have any locked jobs.
        def self.clear_locks!(worker_name)
          update_all("locked_by = null, locked_at = null", ["locked_by = ?", worker_name])
        end

It works fine until there, but for some reason it says there's no db connection when it calls update_all.

  • delayed_job (3.0.3)
  • delayed_job_active_record (0.3.2)
  • PostgreSAL 9.3.2
  • Mavericks
  • Ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]

Any ideas?

@andrusha

I'm experiencing the same problem, here is the console output if I try to run delayed_job manually:

irb(main):003:0> Delayed::Command.new(['run']).daemonize
delayed_job: process with pid 24896 started.
  SQL (0.9ms)  UPDATE "delayed_jobs" SET locked_at = '2014-06-25 14:23:10.672175', locked_by = 'delayed_job host:andrews-mbp pid:24896' WHERE (id = 267971 and (locked_at is null or locked_at < '2014-06-25 14:18:10.672175') and (run_at <= '2014-06-25 14:23:10.672175'))
   (0.5ms)  BEGIN
PG::ProtocolViolation: FATAL:  invalid frontend message type 0
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
: BEGIN
   (0.4ms)  BEGIN
PG::UnableToSend: no connection to the server
: BEGIN
  SQL (0.3ms)  UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:andrews-mbp pid:24896')
PG::UnableToSend: no connection to the server
: UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:andrews-mbp pid:24896')
PG::UnableToSend: no connection to the server
: UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:andrews-mbp pid:24896')
/Users/andrew/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/irb.rb:412:in `throw': uncaught throw :IRB_EXIT (ArgumentError)
    from /Users/andrew/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/irb.rb:412:in `irb_exit'
    from /Users/andrew/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/irb/context.rb:392:in `exit'
    from /Users/andrew/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/irb/extend-command.rb:29:in `irb_exit'
    from /Users/andrew/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:80:in `block in <top (required)>'
@albus522
Collective Idea member

Try recent versions of everything

@albus522 albus522 closed this Sep 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment