#36263: DB connection is not recreated after it closed due to time out.
-------------------------------------+-------------------------------------
     Reporter:  Sivakajan Sivaparan  |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  DB, Connection-      |             Triage Stage:
  close, ensure_connection           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * resolution:   => invalid
 * status:  new => closed

Comment:

 Please refer to the
 [https://docs.djangoproject.com/en/5.1/ref/databases/#caveats database
 documentation about caveats]

 > If a connection is created in a long-running process, outside of
 Django’s request-response cycle, the connection will remain open until
 explicitly closed, or timeout occurs. You can use
 `django.db.close_old_connections()` to close all old or unusable
 connections.

 In other words, outside of the request-response cycle Django has no entry
 point to determine when the connection should be ping'ed to determine if
 it should be closed and re-opened and performing a ping before every
 single query is not desirable so `CONN_HEALTH_CHECKS`
 [https://docs.djangoproject.com/en/5.1/ref/settings/#conn-health-checks
 has no effect there].

 > If set to True, existing persistent database connections will be health
 checked before they are reused **in each request** performing database
 access.

 You should explicitly call `close_old_connections` before every code path
 outside of request-response cycle that interacts with the database and
 could be idling for longer than your configured connection timeouts.

 See #32589 for more details on the above and #24810 about trying to re-
 open connections automatically when no transaction is active.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36263#comment:1>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070195a9f810de-45d26c28-f76f-4d21-86aa-516f72fcd7ef-000000%40eu-central-1.amazonses.com.

Reply via email to