MySQL Forums
Forum List  »  Connector/Python

Re: mysql-connector-python starting from 8.0.12 goes to infinite loop when iterates till the end of table
Posted by: Alexey Chernov
Date: May 02, 2020 11:38AM

[djadm@probeg mainsite]$ ./manage.py shell
Python 3.6.8 (default, Apr 2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from results.models import *

>>> q1=Club.objects.all()
>>> q1.query
<django.db.models.sql.query.Query object at 0x7f6813cac588>
>>> print(q1.query)
SELECT `KLB1`.`IDKLB`, `KLB1`.`titul` FROM `KLB1`
>>> a=[x for x in q1]
[process killed after ~10 minutes of working with all available memory]

>>> q2=Club.objects.all()[:200]
>>> print(q2.query)
SELECT `KLB1`.`IDKLB`, `KLB1`.`titul` FROM `KLB1` LIMIT 200
>>> a=[x for x in q2]
[Finishes immediately]

>>> q3=Club.objects.all()[:201]
>>> q3.query
<django.db.models.sql.query.Query object at 0x7f56f5675860>
>>> print(q3.query)
SELECT `KLB1`.`IDKLB`, `KLB1`.`titul` FROM `KLB1` LIMIT 201
>>> a=[x for x in q3]
[I stopped it after ~30sec, the trace is below]

^CTraceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/models/query.py", line 274, in __iter__
self._fetch_all()
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/models/query.py", line 1242, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/models/query.py", line 55, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/models/sql/compiler.py", line 1173, in execute_sql
return list(result)
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/models/sql/compiler.py", line 1552, in cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/models/sql/compiler.py", line 1552, in <lambda>
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/local/venv/main/lib64/python3.6/site-packages/django/db/utils.py", line 96, in inner
return func(*args, **kwargs)
File "/usr/local/venv/main/lib64/python3.6/site-packages/mysql/connector/cursor_cext.py", line 511, in fetchmany
if size and self._cnx.unread_result:
File "/usr/local/venv/main/lib64/python3.6/site-packages/mysql/connector/connection_cext.py", line 610, in unread_result
return self.result_set_available
KeyboardInterrupt

Options: ReplyQuote




Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.