Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility timeout set in celery config does not work, celery still using the default 1 hour #7651

Closed
4 tasks done
la-luo-unit21 opened this issue Jul 25, 2022 · 10 comments
Closed
4 tasks done

Comments

@la-luo-unit21
Copy link

Checklist

  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the master branch.
  • I have included all related issues and possible duplicate issues in this issue
    (If there are none, check this box anyway).

Related Issues and Possible Duplicates

Related Issues

Here is how we write the configs file:

result_expires = 60
task_acks_late = True  # enables retry on task failure
worker_prefetch_multiplier = 1  # reserving one task at a time
accept_content = ['json']
result_extended = True
broker_transport_options = {
    'queue_order_strategy': 'round_robin',
    'visibility_timeout': 7200  # by seconds, 2 hours
}
task_send_sent_event = True

Here is how we configure the worker:

        celery = Celery(
            __name__,
            broker=config.CELERY_BROKER_URL,
            backend=config.CELERY_RESULT_BACKEND
        )

        os.environ.setdefault(
            'CELERY_CONFIG_MODULE',
            'celeryconfigs.default'
        )
        celery.config_from_envvar('CELERY_CONFIG_MODULE')
        celery.conf.ONCE = {
            'backend': 'celery_once.backends.Redis',
            'settings': {
                'url': config.CELERY_BROKER_URL,
                'default_timeout': 60 * 60
            }
        }

However, tasks running long still get redelivered after 1 hour as the default visibility timeout, not 2 hours as we set. We are following the docs https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-transport-options What could we possibly miss?

Possible Duplicates

  • None

Description

Suggestions

@open-collective-bot
Copy link

Hey @la-luo-unit21 👋,
Thank you for opening an issue. We will get back to you as soon as we can.
Also, check out our Open Collective and consider backing us - every little helps!

We also offer priority support for our sponsors.
If you require immediate assistance please consider sponsoring us.

@andyzheung
Copy link

do you solve this problem? @la-luo-unit21

@la-luo-unit21
Copy link
Author

do you solve this problem? @la-luo-unit21

Hi we are still experiencing this and see if someone can shed some light here

@auvipy
Copy link
Member

auvipy commented Aug 16, 2022

#7696 is a duplicate

@auvipy
Copy link
Member

auvipy commented Aug 16, 2022

you are using redis or SQS transports right? and this is happening in 5.3.0b1?

@liuzm7188
Copy link

liuzm7188 commented Sep 29, 2022

I have the same issue, and a task is still in unacked queue. When I restart celery worker, the task doesn't get redelivered, so it lossed.
celery==5.2.7
redis==4.3.4
kombu=5.2.4

task_reject_on_worker_lost = True
task_acks_late = True
broker_transport_options = {
'visibility_timeout': 1800,
'health_check_interval': 10
}

@srijan-scanova
Copy link

Hi there, I'm using celery with SQS and having the same issue with the countdown 30 min in apply_async args. Please, if you could prioritise this bug, then this would be a great help!

@auvipy auvipy added this to the 5.3 milestone Oct 19, 2022
@sVathis
Copy link

sVathis commented Dec 13, 2022

After a lot of testing I found that in order changes in visibility_timeout value to take effect, one must set it in all, celery config, result backend & transport options, as follows :
visibility_timeout = 600
result_backend_transport_options = broker_transport_options = { 'visibility_timeout': 600 }
So the reported behavior might not be a product defect per se, just lack of proper documentation

@auvipy auvipy modified the milestones: 5.3, 5.3.x Dec 14, 2022
@auvipy
Copy link
Member

auvipy commented Dec 14, 2022

After a lot of testing I found that in order changes in visibility_timeout value to take effect, one must set it in all, celery config, result backend & transport options, as follows : visibility_timeout = 600 result_backend_transport_options = broker_transport_options = { 'visibility_timeout': 600 } So the reported behavior might not be a product defect per se, just lack of proper documentation

would you mind sending a PR to improve the documentation?

@pangyuteng
Copy link

pangyuteng commented Jul 21, 2023

To those using rabbitmq as broker, please checkout the "Warning" section under "Calling - ETA and Countdown".
https://docs.celeryq.dev/en/stable/userguide/calling.html#eta-and-countdown
Due to rabbitmq version updates, your rabbitmq config may need to be updated to bump the consumer timeout to a very large value, e.g. consumer_timeout = 31622400000.

in ubuntu, you can set this variable in /etc/rabbitmq/rabitmq-env.conf by adding the below line.
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbit consumer_timeout 31622400000"
https://stackoverflow.com/a/73928874/868736

auvipy pushed a commit that referenced this issue Aug 22, 2023
@auvipy auvipy closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants