Repository navigation
Description
I realize MongoDB is not a supported backend, but I since there is code included for it, I thought I would try to get this feature working. At least it would be good to have it report an appropriate exception instead of silently failing.
Checklist
- I have included the output of
celery -A proj reportin the issue.
(if you are not able to do this, then at least specify the Celery
version affected). - I have verified that the issue exists against the
masterbranch of Celery.
software -> celery:4.1.0 (latentcall) kombu:4.1.0 py:3.6.3
billiard:3.5.0.3 pymongo:3.6.1
platform -> system:Linux arch:64bit, ELF imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:mongodb results:mongodb://mypreview_celery:**@astdc-mongo01p.dimensional.com%2Castdc-mongo02p.dimensional.com%2Castdc-mongo03p.dimensional.com/mypreview_celery
CELERY_INCLUDE: ['clientsite.accounts.tasks',
'clientsite.funds.utils',
'clientsite.layout.gen',
'clientsite.notify.tasks',
'snapshot.tasks']
BROKER_URL: 'mongodb://mypreview_celery:@astdc-mongo01p..com,astdc-mongo02p..com,astdc-mongo03p..com/mypreview_celery'
CELERY_RESULT_BACKEND: 'mongodb://mypreview_celery:@astdc-mongo01p..com%2Castdc-mongo02p..com%2Castdc-mongo03p..com/mypreview_celery'
CELERY_MONGODB_BACKEND_SETTINGS: {
'database': '********'}
CELERY_TRACK_STARTED: True
CELERY_SEND_TASK_SENT_EVENT: True
CELERY_SEND_TASK_ERROR_EMAILS: False
ADMINS:
(('IT Comms Support', '[email protected]'),)
SERVER_EMAIL: 'Webmaster [email protected]'
EMAIL_HOST: 'localhost'
EMAIL_PORT: 25
Steps to reproduce
Create a chord with a single task in the header group. Run it asynchronously and both the header task and the body task are executed in series as expected.
Add one more task to the header group of the chord, and run it asynchronously.
The tasks in the header group are executed in parallel but when they complete the callback (body) task is never executed. It's as if celery doesn't notice that the group is complete.
For example, this works:
task_id_list = [1]
batch_id = 'ASD123'
report_jobs = group(tasks.generate_snapshot.s(id) for id in task_id_list)
all_jobs = chord(report_jobs, (tasks.zip_snapshot_batch.s(batch_id=batch_id) |
tasks.notify_generation_batch_completion.s(batch_id=batch_id)))
all_jobs.delay()
But after changing the task_id_list to [1,2] the generate_shapshot tasks are executed in parallel but the zip_snapshot and notify_generation tasks are never called.
Expected behavior
The callback should be called regardless of how many tasks are in the group, when all the groups tasks are complete.
Actual behavior
The callback is called only if there is a single task in the group.
It looks like the code intends to save group results to the 'celery_groupmeta' collection in mongodb. But it doesn't actually save anything to this collection.
Comments
I suppose (not verified) that the single task chord header works because it is interpreted as a chain which doesn't require the saving of groups results.
If the maintainers think it's appropriate, I could try to fix this using the current code. Or try
a different implementation of MongoBackend subclassed from KeyValueStoreBackend, since it implements some nice features like the increment counting, which should work in mongo.
Activity
auvipy commentedon Jun 26, 2019
current status with celery 4.4rc2?
aleksvidak commentedon Jul 30, 2020
I can confirm this issue still exists in celery==4.4.6, has anyone found a workaround?
auvipy commentedon Jul 31, 2020
even in master?
aleksvidak commentedon Jul 31, 2020
Yes, just tried it. If it helps, I have one worker with default concurrency (4 cores).
auvipy commentedon Jul 31, 2020
can you please provide a test case?
nmoreaud commentedon Jan 25, 2022
Could you add documentation about what is supported or not for each result backend type?
Coud you add recommandations about which result backend to choose? (best support)
There used to be some information but it have been removed: https://docs.celeryproject.org/en/3.1/getting-started/brokers/mongodb.html
https://docs.celeryproject.org/en/v5.2.3/getting-started/introduction.html#get-started
auvipy commentedon Jan 25, 2022
it's was planned to be removed but should be supported now
nmoreaud commentedon Jan 25, 2022
I have a doubt, I am encountering infinite loops with basic example chord (see last comment of this ticket:
#3709)