Repository navigation
Open
Description
I was running into errors caused by loading truncated pickled results. Specifically, I would get an EOFError (see below). I eventually figured out that the result column of the celery_taskmeta MySQL table was not able to hold all of the pickled result data. By altering the table to use LONGBLOB instead of BLOB, I was able to deal with the large results (alter table celery_taskmeta modify result LONGBLOB). Is there a way to make this the default type in the future?
[2011-08-31 13:34:13,605: ERROR/PoolWorker-1]
Traceback (most recent call last):
File "/home/ubuntu/w/apis/trunk/apis/celerytasks/tasks/file_task_base.py", line 293, in process
self.process_records()
File "/home/ubuntu/w/apis/trunk/apis/celerytasks/tasks/proxmatch_file.py", line 381, in process_records
self.wait_results(async_result_buffer)
File "/home/ubuntu/w/apis/trunk/apis/celerytasks/tasks/proxmatch_file.py", line 435, in wait_results
async_result.wait()
File "/usr/local/lib/python2.6/dist-packages/celery/result.py", line 87, in wait
return self.get(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/celery/result.py", line 83, in get
interval=interval)
File "/usr/local/lib/python2.6/dist-packages/celery/backends/base.py", line 110, in wait_for
status = self.get_status(task_id)
File "/usr/local/lib/python2.6/dist-packages/celery/backends/base.py", line 206, in get_status
return self.get_task_meta(task_id)["status"]
File "/usr/local/lib/python2.6/dist-packages/celery/backends/base.py", line 227, in get_task_meta
meta = self._get_task_meta_for(task_id)
File "/usr/local/lib/python2.6/dist-packages/celery/backends/database.py", line 61, in _get_task_meta_for
task = session.query(Task).filter(Task.task_id == task_id).first()
File "/usr/local/lib/python2.6/dist-packages/sqlalchemy/orm/query.py", line 1770, in first
ret = list(self[0:1])
File "/usr/local/lib/python2.6/dist-packages/sqlalchemy/orm/query.py", line 1667, in __getitem__
return list(res)
File "/usr/local/lib/python2.6/dist-packages/sqlalchemy/orm/query.py", line 1960, in instances
rows = [process[0](row, None) for row in fetch]
File "/usr/local/lib/python2.6/dist-packages/sqlalchemy/orm/mapper.py", line 2600, in _instance
populate_state(state, dict_, row, isnew, only_load_props)
File "/usr/local/lib/python2.6/dist-packages/sqlalchemy/orm/mapper.py", line 2454, in populate_state
populator(state, dict_, row)
File "/usr/local/lib/python2.6/dist-packages/sqlalchemy/orm/strategies.py", line 150, in new_execute
dict_[key] = row[col]
File "/usr/local/lib/python2.6/dist-packages/celery/db/a805d4bd.py", line 55, in process
return loads(value)
EOFError
Activity
ask commentedon Aug 31, 2011
I think we'd prioritise small results first, as this is the most common use case, but if a blob is not big enough to hold
"reasonably" sized results, then longblob wold be a good default.
Could we find out the current limit for blobs in mysql? What are the space implications for smaller results?
ask commentedon Sep 1, 2011
Yeah, I know about strict mode, that it's not enabled by default is kind of unique to MySQL, and often criticised.
It's one of the first things I enable on new MySQL installs.
16bits is very small indeed, we should definitely increase that.
It seems that a
BLOBin Oracle is2**32by default: http://ss64.com/ora/syntax-datatypes.htmlIn PostgreSQL it seems that the
byteatype is preferred, and that it is of unlimited size. MaybeBLOBmaps to this field directly. I couldn't find any information about whether any of the SQL standardsdescribe dimensions for the
BLOBfield type.django-celery uses django-picklefield, and pickled data is stored in a text field
there: https://github.com/shrubberysoft/django-picklefield/blob/master/src/picklefield/fields.py
I checked
django.db.backends.mysql.creationandTextFieldsusesLONGTEXTon MySQL.picklefield also uuencodes the data though, and there is an issue open for the sqlalchemy backend to use the same
method so the backends can be interchangeable: #183
I think maybe we should resolve issue #183 at the same time so we don't have to change the types that often.
Which means changing the
BLOBto be aLONGTEXTask commentedon Aug 30, 2012
On further inspection this is behavior from SQLAlchemy, where
sqlalchemy.types.PickleTypeis aLargeBinaryfield that resolves to aBLOBwhen using MYSQL. Sadly there is no generic data type in sqlalchemy that is larger than aLargeBloband so if we used aLARGE_BLOBit would not be compatible with all other supported databases.I think sqlalchemy must be lobbied to change the default large binary type for MySQL, or people depending on large results must alter the table :(
ericraymond commentedon Nov 28, 2018
Is there a resolution on this before it was closed?
georgepsarakis commentedon Nov 29, 2018
@ericraymond the database result backend still uses PickleType, which maps to a
LargeBinaryfield in SQLAlchemy as far as I can tell. I suggest that you review the previous comments and if you can provide or propose a solution please feel free to open a new issue.ericraymond commentedon Nov 29, 2018
@georgepsarakis I see your point.
Celery could directly use the MySQL longblob type but that would break the abstraction that Celery uses sqlalchemy for multiple database dialects. The other alternatives are for SQLAlchemy to change the MySQL dialect mapping or create a new (largeblob) MySQL Dialect.
georgepsarakis commentedon Nov 30, 2018
@ericraymond I think I came up with a possible solution. We can redefine the field as LargeBinary and handle the pickling part separately (before storing the result). From the documentation, you can pass a length parameter to the field definition, which MySQL will then map to the corresponding type (
MEDIUMBLOB,LONGBLOB) that can contain binary strings of this length:What do you think?
ericraymond commentedon Nov 30, 2018
17 remaining items
ericraymond commentedon Aug 11, 2021
Is this part of 5.2?
thedrow commentedon Aug 17, 2021
I'm sorry I couldn't get to this in 5.1.
I'm hoping I'll have time to finish this by 5.2.
alexpotv commentedon Aug 19, 2024
Commenting to show interest! For now, I've bypassed this feature by manually adjusting the column type in my migration files, but would really love to see it implemented!
mvhconsult commentedon Jan 31, 2025
Any progress? I am trying out a sql backend (MariaDB) but most tasks now fail due to this storage size.
auvipy commentedon Feb 1, 2025
I will revisit this after celery 5.5 release
APX403 commentedon Nov 27, 2026
Still happens on main (22be744) with MariaDB 10.11 in its default strict mode: a task returning 70,000 bytes ends in
FAILUREwithData too long for column 'result', andGroupResult.save()with 1,200 results fails the same way. Since #10536 the column holds the configured serializer's output in aLargeBinary, so aLONGBLOBvariant for the mysql and mariadb dialects, asDialectSpecificIntegerdoes for MSSQL, would fix new tables, with a note in the docs giving theALTER TABLEfor existing ones. Would you take a PR for that?auvipy commentedon Nov 28, 2026
@ghirailghiro can you check this?