Thursday, January 19, 2017

Re: What is the fate of closed database connections?

It looks like the source of this error is related to a spatialite internal connection leak (discussed in this post: https://groups.google.com/forum/#!topic/spatialite-users/xrV7CA_GlwM)

Each time Django requests a connection to the database sqlite loads the spatialite extension module, which creates an internal database connection that persists after Django closes its connection. This seems to explain why enabling persistent connections fixes the issue on my local machine.

Apart from this workaround I don't know if there is another solution. The post linked above discusses one strategy but I'm not sure it is possible with python's sqlite bindings.
 

On Wednesday, January 18, 2017 at 9:39:53 AM UTC-5, Tom Evans wrote:
On Tue, Jan 17, 2017 at 7:58 PM, Fred Stluka <fr...@bristle.com> wrote:
> Mike,
>
> As of version 1.6, Django supports persistent DB connections
> (connection pooling).

Pedantry: Persistent connections are not the same as connection
pooling. With persistent connections, if a worker does not have a
currently open connection to the database, it will open a new one.
With a connection pool, it will retrieve an unused open connection
from the pool, which is shared amongst many processes.

Connection pools are not built in to django, but you can use external
software like pgbouncer to provide them.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7cf9cc7e-0cbb-4fe3-9491-389a96e01a8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment