Hallöchen!

Malcolm Tredinnick writes:

> On Wed, 2008-11-19 at 10:21 +0900, Ian Lewis wrote:
>
>> I've run into the following error in a SQL DB envornment and was
>> wondering if any one else had run into problems with Deadlocking
>> with MySQL. What would be the proper way to handle this kind of
>> error in Django?
>> 
>> Do most folks simply catch the OperationalError and show some
>> sort of error to the user?
>
> That sounds reasonable.
>
> More substantive for our purposes, though, would be knowing why
> this occurred and if there was any way to avoid it.

I got an OperationalError (1213, 'Deadlock found when trying to get
lock; try restarting transaction') with an M2M relationship.  With

    class Process(models.Model):
        ...

    class Sample(models.Model):
        ...
        processes = models.ManyToManyField(Process, blank=True,
                                           related_name="samples",
                                           verbose_name=_(u"processes"))

the line

    my_process.samples = self.samples_form.cleaned_data["sample_list"]

triggered the exception.  I was running the Django app with Apache,
having MySQL on the same machine (one core).  I started two client
bots that connected with high frequency to the Apache and executed
this line in the Django app quasi-parallely.

I used InnoDB with the transaction middleware (one transaction per
request).

Apparently, a M2M relationship may lead to this exception in this
scenario.  I can't tell whether this needs to be improved in Django,
or whether I have to catch and retry it on the view level.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                   Jabber ID: torsten.bron...@jabber.rwth-aachen.de


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to