[Django] #30646: close_if_unusable_or_obsolete fails to close unusable connections

17 views
Skip to first unread message

Django

unread,
Jul 17, 2019, 1:56:33 PM7/17/19
to django-...@googlegroups.com
#30646: close_if_unusable_or_obsolete fails to close unusable connections
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
dneuhaeuser-zalando |
Type: Bug | Status: new
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
BaseDatabaseWrapper.close_if_unusable_or_obsolete doesn't always close
unusable connections. A connection is only tested for usability, if an
error has occurred on that connection previously. However a connection
might be unusable for other reasons such as database failover.

As we run databases in Kubernetes (using https://github.com/zalando
/postgres-operator), a database failover is not an unusual scenario and
not of any concern. However on employee-facing internal applications that
see relatively low traffic, this leads to a number of requests failing
with 500s on every failover. We've patched this in our applications but it
would be nice to see this fixed in Django itself.

Fixing this does incur the cost of a roundtrip to the database with every
request but this doesn't appear to have any significant impact on latency.

--
Ticket URL: <https://code.djangoproject.com/ticket/30646>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 17, 2019, 2:07:59 PM7/17/19
to django-...@googlegroups.com
#30646: close_if_unusable_or_obsolete fails to close unusable connections
-------------------------------------+-------------------------------------
Reporter: dneuhaeuser-zalando | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by dneuhaeuser-zalando):

I've created a PR to fix the problem:
https://github.com/django/django/pull/11573

--
Ticket URL: <https://code.djangoproject.com/ticket/30646#comment:1>

Django

unread,
Jul 17, 2019, 2:26:50 PM7/17/19
to django-...@googlegroups.com
#30646: close_if_unusable_or_obsolete fails to close unusable connections
-------------------------------------+-------------------------------------
Reporter: dneuhaeuser-zalando | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

Hello there,

> Fixing this does incur the cost of a roundtrip to the database with
every request but this doesn't appear to have any significant impact on
latency.

I'm afraid we can't take an anecdotical report about effects on your setup
to stand for most of other setups out there. What if someone reports that
it significantly affects ''their'' setup?

I guess we could add a flag to `close_if_unusable_or_obsolete` for this
purpose but it seems wasteful to perform this check on every request. If
we decide that this should be done we should at least move the ''
obsolescence '' check before the ''usable'' one since the former doesn't
require any database interactions and will be reached on all requests when
`CONN_MAX_AGE=0` which is the default.

--
Ticket URL: <https://code.djangoproject.com/ticket/30646#comment:2>

Django

unread,
Jul 18, 2019, 1:16:46 AM7/18/19
to django-...@googlegroups.com
#30646: close_if_unusable_or_obsolete fails to close unusable connections.

-------------------------------------+-------------------------------------
Reporter: dneuhaeuser-zalando | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

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


Comment:

Thanks for the report, however I agree with Simon that checking this on
every request seems like an overkill.

Please write to the DevelopersMailingList if you want other opinions, we
can re-open this ticket if we reach a consensus on the mailing list.

--
Ticket URL: <https://code.djangoproject.com/ticket/30646#comment:3>

Reply all
Reply to author
Forward
0 new messages