Opened 5 years ago

Closed 5 years ago

#22879 closed Bug (fixed)

Database errors coming from cursor iterator are not converted to Django database errors

Reported by: denisenkom@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


Here is one possible situation:

Traceback (most recent call last):
  File "/opt/python-2.7/lib/python2.7/", line 552, in __bootstrap_inner
  File "/opt/python-2.7/lib/python2.7/", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/denisenk/django-sqlserver/env/src/django/tests/select_for_update/", line 245, in raw
  File "/home/denisenk/django-sqlserver/env/src/django/django/db/models/", line 1427, in __iter__
    for values in query:
  File "/home/denisenk/django-sqlserver/env/lib/python2.7/site-packages/", line 473, in next
    return type(self).__next__(self)
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/", line 703, in __next__
    row = self.fetchone()
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/", line 676, in fetchone
    row = self._session.fetchone()
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/", line 3429, in fetchone
    if not self.next_row():
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/", line 3443, in next_row
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/", line 2654, in process_end
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/", line 2443, in raise_db_exception
    raise ex
OperationalError: Lock request time out period exceeded.

Change History (7)

comment:1 Changed 5 years ago by Tim Graham

Component: UncategorizedDatabase layer (models, ORM)
Has patch: set

comment:2 Changed 5 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:3 Changed 5 years ago by Aymeric Augustin

Type: UncategorizedBug

comment:4 Changed 5 years ago by Thomas Chaumeny

Needs tests: set
Patch needs improvement: set

As discussed on, the patch could be simplified a bit.

comment:5 Changed 5 years ago by Tim Graham

Patch needs improvement: unset

Patch is now simpler. How about including a regression test for MSSQL Server even if it passes on all the bundled backends?

comment:6 Changed 5 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

According to the PR, there is already such a test in Django's test suite.

comment:7 Changed 5 years ago by Anssi Kääriäinen <akaariai@…>

Resolution: fixed
Status: newclosed

In d4bc0bf435402f32d1e31aeffd280276349283d8:

Fixed #22879 -- Intercept errors coming from

Note: See TracTickets for help on using tickets.
Back to Top