#12387: TransactionRollbackError when there are more ForeignKey's to one table
---------------------------+------------------------------------------------
 Reporter:  [email protected]  |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.1       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 Postgres backend. When there is more references to one table with
 ForeignKey in same model sometimes there is thrown Exception (not always).

 File "/usr/local/lib/python2.6/site-packages/django/db/models/base.py",
 line 410, in save
    self.save_base(force_insert=force_insert, force_update=force_update)

  File "/usr/local/lib/python2.6/site-packages/django/db/models/base.py",
 line 495, in save_base
    result = manager._insert(values, return_id=update_pk)

  File "/usr/local/lib/python2.6/site-
 packages/django/db/models/manager.py", line 177, in _insert
    return insert_query(self.model, values, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/db/models/query.py",
 line 1087, in insert_query
    return query.execute_sql(return_id)

  File "/usr/local/lib/python2.6/site-
 packages/django/db/models/sql/subqueries.py", line 320, in execute_sql
    cursor = super(InsertQuery, self).execute_sql(None)

  File "/usr/local/lib/python2.6/site-
 packages/django/db/models/sql/query.py", line 2369, in execute_sql
    cursor.execute(sql, params)

 TransactionRollbackError: deadlock detected
 DETAIL:  Process 40975 waits for ShareLock on transaction 172977254;
 blocked by process 40961.
 Process 40961 waits for ShareLock on transaction 172977277; blocked by
 process 40975.
 HINT:  See server log for query details.
 CONTEXT:  SQL statement "SELECT 1 FROM ONLY "public"."foo_bar" x WHERE
 "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x"

 Example of model:

 class bar(models.Model):
  baz = models.ForeignKey('some.model', related_name='sm')
  other = models.ForeignKey('some.model', related_name='so')

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12387>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--

You received this message because you are subscribed to the Google Groups 
"Django updates" 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/django-updates?hl=en.


Reply via email to