#29760: Cursors are being closed explicitly in autocommit mode
-------------------------------------+-------------------------------------
Reporter: Ali Teoman Unay | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: cursor, sql, | Triage Stage: Accepted
database, autocommit, |
transactions, postrgresql, |
psycopg |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Kurt Wheeler):
I'm getting the same error, while using the `iterator()` method of a
queryset:
{{{
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line
96, in inner
return func(*args, **kwargs)
psycopg2.OperationalError: cursor "_django_curs_140027036677888_1" does
not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-
packages/django/db/models/sql/compiler.py", line 1512, in cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/local/lib/python3.5/dist-
packages/django/db/models/sql/compiler.py", line 1512, in <lambda>
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line
96, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line
89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line
96, in inner
return func(*args, **kwargs)
django.db.utils.OperationalError: cursor "_django_curs_140027036677888_1"
does not exist
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/data_refinery_workers/processors/utils.py", line 369,
in run_pipeline
last_result = processor(last_result)
File "/home/user/data_refinery_workers/processors/qn_reference.py", line
241, in _update_caches
for experiment in unique_experiments.iterator():
File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py",
line 341, in _iterator
yield from self._iterable_class(self, chunked_fetch=use_chunked_fetch,
chunk_size=chunk_size)
File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py",
line 72, in __iter__
for row in compiler.results_iter(results):
File "/usr/local/lib/python3.5/dist-
packages/django/db/models/sql/compiler.py", line 1515, in cursor_iter
cursor.close()
psycopg2.OperationalError: cursor "_django_curs_140027036677888_1" does
not exist
}}}
This is the line of code that is causing that error
https://github.com/AlexsLemonade/refinebio/blob/dev/workers/data_refinery_workers/processors/qn_reference.py#L241
Any idea why my cursor is disappearing? I don't think I'm doing anything
unusual in my code there. The queryset it's iterating over seems to be
~20k records.
The only other thing I can think of that might be non-standard about my
configuration is that I have a pg_bouncer instance set up to batch
database connections. It seems to do a good job of pretending to be the
postgres server itself, but maybe this is a place that it doesn't?
--
Ticket URL: <https://code.djangoproject.com/ticket/29760#comment:9>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.429772ffa23e3a6e0070df8e21bb65fc%40djangoproject.com.