#24810: Reopen database connection automatically when no transaction is active
-------------------------------------+-------------------------------------
               Reporter:  aaugustin  |          Owner:  nobody
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  master
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:  Accepted   |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This is a follow-up of #15802.

 When the database closes the connection, for instance because the database
 server was restarted, an exception will be raised the next time user code
 attempts to use the database. Django doesn't attempt to do anything about
 it.

 This is expected to result in at most one 500 error for each thread that
 serves requests, since database connections are thread-local. This doesn't
 sound horrific. After all the database was restarted while the website was
 serving requests.

 It can also cause management commands to crash, which isn't the end of the
 world either since management commands should fall into one of the
 following categories:
 - short-lived, idempotent and scheduled to run regularly
 - long-lived and supervised to run constantly
 - run manually

 If the connection was in autocommit mode and an operation fails because
 the database has closed the connection, theoretically, it's safe the
 reopen the connection and retry the operation.

 In that case, Django could continue to operate transparently instead of
 raising an exception.

 This may not be easy to implement.

--
Ticket URL: <https://code.djangoproject.com/ticket/24810>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.169dff053fe2864d216a7fae7d207a1e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to