[darcs-users] new version of trac-darcs plugin

Pedro Melo melo at simplicidade.org
Thu Aug 10 10:39:47 UTC 2006


Hi,

On 2006/08/10, at 06:50, K.S.Sreeram wrote:
> 1) Race condition in getting file content (DarcsNode.get_content)
> The logic used is:
>   - Check if data is cached in db, if yes, load it and return it
>   - Fetch data from darcs repository
>   - Insert the data into the cache
>   - Return the data
> As can be seen, a db error occurs when 2 or more requests try to  
> access
> the same uncached db data. It fails because the code tries to  
> insert the
> same data into the db twice. What is the best approach for solving  
> this
> problem? I'm not sure how to use a mutex-like object in this scenario.

I would suggest one of two approaches:
  - ignore the error in the second insert;
  - catch the error in the second insert, fetch the data from the DB,  
compare with the data you would be inserting into the DB.

Assuming that your key is really a unique mapping from db data to a  
darcs thingy, the data you are trying to insert and the data that won  
the race into the DB is the  same, so the first choice is acceptable.

best regards,
--
Pedro Melo
JID: xmpp:melo at simplicidade.org






More information about the darcs-users mailing list