Sorry for the continuing post spam... However, I think I know what is
causing this problem. What tipped me off is I am seeing multiple
copies of the same item in my shopping cart if I really hammer at the
"add cart" button (instead of a single item with a quantity > 1). Each
of these are an AJAX call and therefore I think can processed prior to
the previous call returning. What happens is:
- I load the shopping cart (and other stuff)
- I start a transaction
- I check to see if the item is already in the cart. If its there I
increment the quantity, if not I add a new item to the cart.
- I commit the transaction

What can I suspect is the addCart can be called concurrently -- the
transaction protects the database lock, but not the now cached data in
the in-memory model. This also likely caused the removeCart issue that
occurs above since it probably results in removing the same cart item
twice causing an error when one of them is flushed to the database.

So what is the correct solution here? I don't think that mutex
protection of the cart model itself will work as each copy of the cart
is presumably a new copy of the underlying data. I could, of course,
protect the actual addCart and removeCart method in the web server (as
opposed to the model). However, that sucks since it precludes multi-
threaded access to separate carts which should be possible.

Any ideas?

Regards, Matthew

On Nov 2, 6:53 pm, Matthew Newhook <[EMAIL PROTECTED]> wrote:
> Sorry, my post got garbled a bit!
>
> What I meant to say was that changing the isolation_level to immediate
> helped with the problem in that its more difficult (but not
> impossible, of course) to get a deadlock error as before. However, now
> I've run into a new problem. The details follow in my original post.
>
> Regards, Matthew


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to