Skip to content

Instantly share code, notes, and snippets.

@cherring
Created July 20, 2010 04:48
Show Gist options
  • Save cherring/482545 to your computer and use it in GitHub Desktop.
Save cherring/482545 to your computer and use it in GitHub Desktop.
2010-07-16T17:10:45+1000: *** Starting job worker delayed_job host:jfrails2 pid:9214
2010-07-16T17:12:40+1000: * [Worker(delayed_job host:jfrails2 pid:9214)] acquired lock on ScorecardJob
2010-07-16T17:12:40+1000: * [JOB] delayed_job host:jfrails2 pid:9214 failed with ActiveRecord::StatementInvalid: PGError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
: SELECT * FROM "outlets" - 0 failed attempts
2010-07-16T17:12:40+1000: * [Worker(delayed_job host:jfrails2 pid:9214)] acquired lock on ScorecardJob
2010-07-16T17:12:40+1000: * [JOB] delayed_job host:jfrails2 pid:9214 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 1 failed attempts
2010-07-16T17:12:40+1000: 2 jobs processed at 53.2326 j/s, 2 failed ...
2010-07-16T17:13:05+1000: * [Worker(delayed_job host:jfrails2 pid:9214)] acquired lock on ScorecardJob
2010-07-16T17:13:05+1000: * [JOB] delayed_job host:jfrails2 pid:9214 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 2 failed attempts
2010-07-16T17:13:05+1000: * [Worker(delayed_job host:jfrails2 pid:9214)] acquired lock on ScorecardJob
2010-07-16T17:13:05+1000: * [JOB] delayed_job host:jfrails2 pid:9214 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 3 failed attempts
2010-07-16T17:13:05+1000: 2 jobs processed at 98.4786 j/s, 2 failed ...
2010-07-16T17:14:54+1000: Exiting...
2010-07-16T17:15:02+1000: *** Starting job worker delayed_job host:jfrails2 pid:10677
2010-07-16T17:17:27+1000: * [Worker(delayed_job host:jfrails2 pid:10677)] acquired lock on ScorecardJob
2010-07-16T17:17:27+1000: * [JOB] delayed_job host:jfrails2 pid:10677 failed with ActiveRecord::StatementInvalid: PGError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
: SELECT * FROM "outlets" - 4 failed attempts
2010-07-16T17:17:27+1000: * [Worker(delayed_job host:jfrails2 pid:10677)] acquired lock on ScorecardJob
2010-07-16T17:17:27+1000: * [JOB] delayed_job host:jfrails2 pid:10677 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 5 failed attempts
2010-07-16T17:17:27+1000: 2 jobs processed at 52.2521 j/s, 2 failed ...
2010-07-16T17:23:54+1000: Exiting...
2010-07-20T13:53:34+1000: *** Starting job worker delayed_job host:jfrails2 pid:26781
2010-07-20T13:53:34+1000: * [Worker(delayed_job host:jfrails2 pid:26781)] acquired lock on ScorecardJob
2010-07-20T13:55:54+1000: * [JOB] delayed_job host:jfrails2 pid:26781 completed after 139.5005
2010-07-20T13:55:54+1000: 1 jobs processed at 0.0072 j/s, 0 failed ...
2010-07-20T13:56:38+1000: Exiting...
2010-07-20T13:57:19+1000: *** Starting job worker delayed_job host:jfrails2 pid:26828
2010-07-20T13:57:19+1000: * [Worker(delayed_job host:jfrails2 pid:26828)] acquired lock on ScorecardJob
2010-07-20T13:57:19+1000: * [JOB] delayed_job host:jfrails2 pid:26828 failed with ActiveRecord::StatementInvalid: PGError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
: SELECT * FROM "outlets" - 0 failed attempts
2010-07-20T13:57:19+1000: * [Worker(delayed_job host:jfrails2 pid:26828)] acquired lock on ScorecardJob
2010-07-20T13:57:19+1000: * [JOB] delayed_job host:jfrails2 pid:26828 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 1 failed attempts
2010-07-20T13:57:19+1000: 2 jobs processed at 29.2401 j/s, 2 failed ...
2010-07-20T13:57:44+1000: * [Worker(delayed_job host:jfrails2 pid:26828)] acquired lock on ScorecardJob
2010-07-20T13:57:44+1000: * [JOB] delayed_job host:jfrails2 pid:26828 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 2 failed attempts
2010-07-20T13:57:44+1000: * [Worker(delayed_job host:jfrails2 pid:26828)] acquired lock on ScorecardJob
2010-07-20T13:57:44+1000: * [JOB] delayed_job host:jfrails2 pid:26828 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 3 failed attempts
2010-07-20T13:57:44+1000: 2 jobs processed at 92.4008 j/s, 2 failed ...
2010-07-20T13:59:30+1000: Exiting...
2010-07-20T13:59:35+1000: *** Starting job worker delayed_job host:jfrails2 pid:26847
2010-07-20T14:02:05+1000: * [Worker(delayed_job host:jfrails2 pid:26847)] acquired lock on ScorecardJob
2010-07-20T14:04:12+1000: * [JOB] delayed_job host:jfrails2 pid:26847 completed after 126.4229
2010-07-20T14:04:12+1000: 1 jobs processed at 0.0079 j/s, 0 failed ...
2010-07-20T14:09:31+1000: Exiting...
2010-07-20T14:13:05+1000: *** Starting job worker delayed_job host:jfrails2 pid:27290
2010-07-20T14:13:05+1000: * [Worker(delayed_job host:jfrails2 pid:27290)] acquired lock on ScorecardJob
2010-07-20T14:13:05+1000: * [JOB] delayed_job host:jfrails2 pid:27290 failed with ActiveRecord::StatementInvalid: PGError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
: SELECT * FROM "outlets" - 0 failed attempts
2010-07-20T14:13:05+1000: * [Worker(delayed_job host:jfrails2 pid:27290)] acquired lock on ScorecardJob
2010-07-20T14:13:05+1000: * [JOB] delayed_job host:jfrails2 pid:27290 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 1 failed attempts
2010-07-20T14:13:05+1000: 2 jobs processed at 31.8137 j/s, 2 failed ...
2010-07-20T14:13:30+1000: * [Worker(delayed_job host:jfrails2 pid:27290)] acquired lock on ScorecardJob
2010-07-20T14:13:30+1000: * [JOB] delayed_job host:jfrails2 pid:27290 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 2 failed attempts
2010-07-20T14:13:30+1000: * [Worker(delayed_job host:jfrails2 pid:27290)] acquired lock on ScorecardJob
2010-07-20T14:13:30+1000: * [JOB] delayed_job host:jfrails2 pid:27290 failed with ActiveRecord::StatementInvalid: PGError: no connection to the server
: SELECT * FROM "outlets" - 3 failed attempts
2010-07-20T14:13:30+1000: 2 jobs processed at 101.0310 j/s, 2 failed ...
2010-07-20T14:15:10+1000: Exiting...
@rafamvc
Copy link

rafamvc commented Feb 9, 2011

I'm having the exactly same issue. Did you ever figure it out?

@sgrove
Copy link

sgrove commented Feb 9, 2011

It seemed to have worked for me if after the fork, I re-established the db connection. ie.

with_app_env do |env|
  pid = fork do
    fork do
      puts "Disconnecting from DB!"
      defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
      ....code here....
    end
  end

  Process.detach(pid)
end

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

And that solved the problem for me. Please let me know if it works for you!

@rafamvc
Copy link

rafamvc commented Feb 9, 2011

Thanks! I also found that if you run the older version of daemons it works fine too.
But thanks for the code, maybe I will try to fix it on the daemon or on the DJ code itself.

@sgrove
Copy link

sgrove commented Feb 9, 2011

What version of the daemon? 2.1.2?

@rafamvc
Copy link

rafamvc commented Feb 9, 2011

gem 'daemons', '1.0.10'

I got this from another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment