#28062: Using QuerySet.iterator() with pgBouncer leads to nonexistent cursor
errors
-------------------------------------+-------------------------------------
Reporter: Sergey Fursov | Owner: François
| Freitag
Type: Bug | Status: closed
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jdlourenco):
I am running into what seems to be the same problem, however I'm not using
''pgBouncer''.
I'm connecting directly to a **redshift** database and I get this error
using either the **django.db.backends.postgresql_psycopg2** or the
**django_redshift_backend** engines.
{{{
'redshift': {
'NAME': 'dbname',
...
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': 'xxxxxxxxxx.redshift.amazonaws.com',
'PORT': 5439,
}
}}}
I've enabled DEBUG logging and I can see Django creating a server side
cursor by using a ''DECLARE WITH HOLD'' statement. It then issues two
queries and the second fails with a ''cursor "_django_curs_XXXXXXX" does
not exist'' error message. Setting **DISABLE_SERVER_SIDE_CURSORS=true**
seems to solve the issue.
According the Django documentation, this happens due to transaction
pooling resulting in Django using a different connection for which the
named cursor does not exist the second time it issues the query. However I
can't understand why this is happening since afaik I'm not using
''pgBouncer'' nor any other middleware implementing transaction pooling.
Can you help me understand why this is happening?
--
Ticket URL: <https://code.djangoproject.com/ticket/28062#comment:19>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.ce70941f99dbaa9d0029727584f3db49%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.