Saturday, September 24, 2011

Re: Parellel request from the same user in very short time

On Sat, Sep 24, 2011 at 10:08 PM, Martin Tiršel <django@blackpage.eu> wrote:
> Hello,
>
> I am using Apache with mod_wsgi and following setting:
>
> WSGIDaemonProcess dev.xyz.com processes=1 threads=5 user=xyz group=xyz
> display-name=dev.xyz.com
>
> I am observing some situations where a user sends the same request multiple
> times (double click?) where the time between these requests is very low -
> 80-100ms. Then I got these situations (bot request from the same user):
>
> 1. request A - SELECT ...
> 2. request B - SELECT ...
> 3. request A - INSERT ... (insert is based on select result from step 1)
> 4. request B - INSERT ... (insert is based on select result from step 2)
>
> Because 1. and 2. gets the same data, I end with doubled (or sometimes
> trippled) inserts what breaks my application. How do you prevent such
> behaviour? I am using Django 1.2.x

I might be missing something obvious here, but isn't this *exactly*
what database transactions are designed to fix? Admittedly, you've got
an unusual presentation born out of weird browser behavior, but making
sure that two overlapping operations don't violate data integrity
sounds like the textbook case for using transactions.

Yours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate