8000 Database connections being left open · Issue #132 · getsentry/sentry-python · GitHub
[go: up one dir, main page]

Skip to content
Database connections being left open #132
Closed
@jkeyes

Description

@jkeyes

Python: 3.6.5
Django: 2.1.2
sentry-sdk: 0.4.2

I upgraded from raven to sentry-sdk yesterday and noticed my app was now keeping database connections open rather than closing them per request.

I wrote a tiny view to test this:

def sentry_test(request):
    from django.contrib.auth.models import User
    print(User.objects.all())
    return HttpResponse("<h1>Hello</h1>")

and when GET the URL repeatedly I see the subsequent connections remain idle after the request has completed:

=> SELECT state, query FROM pg_stat_activity WHERE client_addr IS NOT NULL;
 state  | query
--------+-----------------------------------------------------
 idle   | SELECT "auth_user"."id", "auth_user"."password", ...
 active | SELECT state, query FROM pg_stat_activity WHERE client_addr IS NOT NULL;
 idle   | SELECT "auth_user"."id", "auth_user"."password", ...
 idle   | SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"
 idle   | SELECT "auth_user"."id", "auth_user"."password", ...
 idle   | SELECT "auth_user"."id", "auth_user"."password", ...
 idle   | SELECT "auth_user"."id", "auth_user"."password", ...

As you can see the connection from the migrate query on startup has remained open too.

If I use raven this behaviour is not exhibited.

I suspect this won't help much, but if I use sentry-sdk and comment out:

        WSGIHandler.__call__ = sentry_patched_wsgi_handler

Then the problem doesn't manifest itself but I've basically turned off sentry at this stage.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0