#21202: Atomic masks fatal database errors and instead propagates "connection
already closed"
-------------------------------------+-------------------------------------
     Reporter:  intgr                |                    Owner:  aaugustin
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |                  Version:
    Component:  Database layer       |  1.6-beta-1
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  1
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by intgr):

 Yeah, the diff in atomic is not really scary at all, here's a whitespace-
 independent diff for 2nd commit:

 {{{#!patch
 diff --git a/django/db/transaction.py b/django/db/transaction.py
 index 86a357f..2a4f16d 100644
 --- a/django/db/transaction.py
 +++ b/django/db/transaction.py
 @@ -18,7 +18,7 @@ from functools import wraps

  from django.db import (
          connections, DEFAULT_DB_ALIAS,
 -        DatabaseError, ProgrammingError)
 +        DatabaseError, ProgrammingError, InterfaceError)
  from django.utils.decorators import available_attrs


 @@ -312,6 +312,7 @@ class Atomic(object):
              connection.in_atomic_block = False

          try:
 +            try:
                  if exc_type is None and not connection.needs_rollback:
                      if connection.in_atomic_block:
                          # Release savepoint if there is one
 @@ -354,6 +355,14 @@ class Atomic(object):
                  elif not connection.savepoint_ids and not
 connection.commit_on_exit:
                      connection.in_atomic_block = False

 +        except InterfaceError:
 +            if exc_type is not None:
 +                # We tried to clean up from an exception, but ran into an
 +                # InterfaceError, meaning the connection is unusable from
 now
 +                # on. Propagate up the original error instead of masking
 it
 +                # with InterfaceError ("connection already closed")
 +                return
 +
      def __call__(self, func):
          @wraps(func, assigned=available_attrs(func))
          def inner(*args, **kwargs):
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21202#comment:4>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.26b6474ba36e5917ac16c93060786a10%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to