Opened 2 years ago

Closed 20 months 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 2 years ago by timo

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 22 months ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 22 months ago by aaugustin

  • Type changed from Uncategorized to Bug

comment:4 Changed 21 months ago by tchaumeny

  • Needs tests set
  • Patch needs improvement set

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

comment:5 Changed 21 months ago by timgraham

  • 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 21 months ago by timgraham

  • Triage Stage changed from Accepted to Ready for checkin

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

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

  • Resolution set to fixed
  • Status changed from new to closed

In d4bc0bf435402f32d1e31aeffd280276349283d8:

Fixed #22879 -- Intercept errors coming from

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