Skip to content

MemoryError caused by big query #909

Description

@todorvelichkov

Recently we started using django-picklefield in order to store a relatively big (1-5 MB) data structure inside one of our models.

So when we call .save() on our Model this creates a big INSERT/UPDATE query and when Django Debug Toolbar process it a MemoryError is being raised.

If we stop the SQL panel from the check-boxes, everything works fine.

We have tried to run reset_queries() immediately after the .save() call but it didn't help.

Here is a Traceback:

Traceback (most recent call last):
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 223, in get_response
    response = middleware_method(request, response)
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/debug_toolbar/middleware.py", line 129, in process_response
    panel.generate_stats(request, response)
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/panel.py", line 192, in generate_stats
    query['sql'] = reformat_sql(query['sql'])
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/utils.py", line 27, in reformat_sql
    return swap_fields(''.join(stack.run(sql)))
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/sqlparse/engine/filter_stack.py", line 34, in run
    for stmt in stream:
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/sqlparse/engine/statement_splitter.py", line 100, in process
    for ttype, value in stream:
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/utils.py", line 14, in process
    for token_type, value in stream:
  File "/home/predator/.virtualenvs/cs-uwsgi/local/lib/python2.7/site-packages/sqlparse/lexer.py", line 48, in get_tokens
    m = rexmatch(text, pos)
MemoryError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions