Opened 10 years ago

Closed 10 years ago

#22146 closed Bug (duplicate)

Database-Connections time out in long running Applications without request context.

Reported by: kahnert Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If you use the Django-ORM outside of request handling, in uWSGI mules for example, connections time out. The expected behavior would be to reconnect on the next command issued.
But because the checks for unusable connections is bound to request signals those get never called.

An easy solution would be to call self.close_if_unusable_or_obsolete() at first in BaseDatabaseWrapper.ensure_connection.

Change History (3)

comment:1 by kahnert, 10 years ago

Since this introduces an infinite recursion, I changed it to if self.connection is not None and not self.is_usable(): self.close() in my testing setup.

comment:2 by Aymeric Augustin, 10 years ago

I'd say it's up to the application to close the connection when it knows it isn't going to use it for some time that may exceed the database's connection timeout :)

What database backend are you using? Isn't this a duplicate of #21597?

comment:3 by Tim Graham, 10 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top