Opened 2 years ago

Closed 2 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

Description

Here is one possible situation:

Traceback (most recent call last):
  File "/opt/python-2.7/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/opt/python-2.7/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/denisenk/django-sqlserver/env/src/django/tests/select_for_update/tests.py", line 245, in raw
    connection.ops.for_update_sql(nowait=True)
  File "/home/denisenk/django-sqlserver/env/src/django/django/db/models/query.py", line 1427, in __iter__
    for values in query:
  File "/home/denisenk/django-sqlserver/env/lib/python2.7/site-packages/six.py", line 473, in next
    return type(self).__next__(self)
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/__init__.py", line 703, in __next__
    row = self.fetchone()
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/__init__.py", line 676, in fetchone
    row = self._session.fetchone()
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/tds.py", line 3429, in fetchone
    if not self.next_row():
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/tds.py", line 3443, in next_row
    self.process_end(marker)
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/tds.py", line 2654, in process_end
    self.raise_db_exception()
  File "/home/denisenk/django-sqlserver/env/src/pytds/pytds/tds.py", 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 Tim Graham

Component: UncategorizedDatabase layer (models, ORM)
Has patch: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 2 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:3 Changed 2 years ago by Aymeric Augustin

Type: UncategorizedBug

comment:4 Changed 2 years ago by Thomas Chaumeny

Needs tests: set
Patch needs improvement: set

As discussed on https://github.com/django/django/pull/2839, the patch could be simplified a bit.

comment:5 Changed 2 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 2 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 2 years ago by Anssi Kääriäinen <akaariai@…>

Resolution: fixed
Status: newclosed

In d4bc0bf435402f32d1e31aeffd280276349283d8:

Fixed #22879 -- Intercept errors coming from cursor.next()

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