[Backgroundrb-devel] A fix for bdrb crash when running in background

hemant gethemant at gmail.com
Wed Jun 18 13:32:20 EDT 2008


On Wed, Jun 18, 2008 at 6:34 PM, Wojciech Knapik
<webmaster at wolniartysci.pl> wrote:
>
> Hi everyone
>
>  I just spent way too much time trying to figure out why the fsck bdrb
> wouldn't run in background (while it worked perfecly in foreground), so I
> figured I'll share my unimpressive solution to save others the trouble.
>  So the problem was that bdrb, when started with `script/backgroundrb
> start`, would exit, with this error msg:
>
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in
> `log': PGError: server closed the connection unexpectedly
> (ActiveRecord::StatementInvalid)
>        This probably means the server terminated abnormally
>        before or while processing the request.
> :           SELECT tablename
>            FROM pg_tables
>           WHERE schemaname IN (E'"$user"',E'public')
>        from
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:395:in
> `query'
>        from
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:441:in
> `tables'
>
>  Starting it with `script/backgroundrb` didn't cause that problem,
> everything worked fine.
>  This happened exactly the same way on a G5/OSX/Postgres 8.2.4/Rails 2.0.2
> workstation and a Xeon/Gentoo/Postgres 8.3.1/Rails 2.0.2 server. Considering
> the different setups and the complete lack of complaints from Postgres, even
> with highest logging verbosity AND the smoothly working rails app, I figured
> it must be a problem with backgroundrb, but whatever changes I tried,
> nothing worked. So fast forward (to spare you the story of the cursing and
> the hopeless googling) - here's the solution - line 32 of
> script/backgroubdrb:
>
>  29 case ARGV[0]
>  30 when 'start'
>  31   if fork
>  32     sleep(5)
>  33     exit
>  34   else
>
>  Apparently leaving the child on it's own too early is not a good thing :-o
>  So there. Here's my good deed for the day.
>


Damn right! Thanks man.


-- 
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org


More information about the Backgroundrb-devel mailing list