[Backgroundrb-devel] not finding activerecord data in worker

Zoltan Olah zol at icyte.com
Sun Sep 14 22:39:47 EDT 2008

Hey guys,

Firstly, I'm new to the list and great work with backgroundrb, it's  
sweet!!! I've just started noticing an issue and i'm wondering if  
there is a standard fix. The situation is as follows:

1. In my model's after_save I call my worker asynchronously with the  
active record object's id as a parameter (the record that has just  
been saved).
2. In my worker, the first thing I do is find the record from the  
database using the id which has been passed in.

What i'm finding is occasionally, in step 2. the worker cannot find  
the record in the db. Having log_bin set in my mysql configuration  
seems to drastically increase the frequency of this happening. It is  
quite clear from the rails logs that the INSERT always happens before  
the call to the backgroundrb worker.

I'm puzzled as I thought the mysql insert query would not return until  
the inserted data is actually in the database and ready to be  
retrieved. It seems to be not the case. The current workaround i'm  
thinking is to put some retrying/sleeping in the backgroundrb worker  
in order to try to wait it out until the record is there. This seems  
to me a last resort. Would love to hear what your experiences are and  
of a better solution if it exists.

many thanks,


More information about the Backgroundrb-devel mailing list