Issue 1:
Checklist

I have verified that the issue exists against the master branch of Celery.

This has already been asked to the discussion group first.

I have read the relevant section in the

contribution guide

on reporting bugs.

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).

Mandatory Debugging Information

I have included the output of celery -A proj report in 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 master branch of Celery.

I have included the contents of pip freeze in the issue.

I have included all the versions of all the external dependencies required

to reproduce this bug.

Optional Debugging Information

I have tried reproducing the issue on more than one Python version

and/or implementation.

I have tried reproducing the issue on more than one message broker and/or

result backend.

I have tried reproducing the issue on more than one version of the message

broker and/or result backend.

I have tried reproducing the issue on more than one operating system.

I have tried reproducing the issue on more than one workers pool.

I have tried reproducing the issue with autoscaling, retries,

ETA/Countdown & rate limits disabled.

I have tried reproducing the issue after downgrading

and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

None

Possible Duplicates

None

Environment & Settings

Celery version: 4.4.7

celery report Output:

Unrecoverable error: PreconditionFailed(406, 'PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more', (0, 0), '')

Steps to Reproduce

Required Dependencies

Minimal Python Version: 3.7

Minimal Celery Version: 4.4.7

Minimal Kombu Version: N/A or Unknown

Minimal Broker Version: RabbitMQ v3.8.21

Minimal Result Backend Version: N/A or Unknown

Minimal OS and/or Kernel Version: N/A or Unknown

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

amqp==5.0.6
arabic-reshaper==2.1.3
asgiref==3.4.1
autopep8==1.5.7
bcrypt==3.2.0
billiard==3.6.4.0
bitstring==3.1.9
blurhash-python==1.1.1
boto3==1.18.24
botocore==1.21.24
CacheControl==0.12.6
cachetools==4.2.2
celery==5.1.2
celery-prometheus-exporter==1.7.0
certifi==2020.12.5
cffi==1.14.6
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.2.0
cryptography==3.4.7
defusedxml==0.7.1
Deprecated==1.2.12
diff-match-patch==20200713
Django==3.2.6
django-admin-tools==0.9.1
django-admintool-command==0.1.1
django-celery-beat==2.2.1
django-celery-results==2.2.0
django-compat==1.0.15
django-extensions==3.1.3
django-import-export==2.5.0
django-ipware==3.0.7
django-oauth-toolkit==1.5.0
django-prometheus==2.1.0
django-shortuuidfield==0.1.3
django-silk==4.1.0
django-storages==1.11.1
django-sympycharfield==0.4.1
django-timezone-field==4.2.1
djangorestframework==3.12.4
drf-recaptcha==2.0.4
ecdsa==0.17.0
esptool==3.1
et-xmlfile==1.1.0
fcm-django==1.0.5
firebase-admin==5.0.2
future==0.18.2
google-api-core==1.31.2
google-api-python-client==2.17.0
google-auth==2.0.0
google-auth-httplib2==0.1.0
google-cloud-core==1.7.2
google-cloud-firestore==2.2.0
google-cloud-storage==1.42.0
google-crc32c==1.1.2
google-resumable-media==1.3.3
googleapis-common-protos==1.53.0
gprof2dot==2021.2.21
grpcio==1.39.0
html5lib==1.1
httplib2==0.19.1
idna==2.10
Jinja2==3.0.1
jmespath==0.10.0
jwcrypto==1.0
kombu==5.1.0
MarkupPy==1.14
MarkupSafe==2.0.1
mpmath==1.2.1
msgpack==1.0.2
oauthlib==3.1.1
odfpy==1.4.1
openpyxl==3.0.7
packaging==21.0
paho-mqtt==1.5.1
phonenumberslite==8.12.30
Pillow==8.3.1
pip-chill==1.0.1
pkg-resources==0.0.0
prometheus-client==0.11.0
prompt-toolkit==3.0.19
proto-plus==1.19.0
protobuf==3.17.3
psycopg2-binary==2.9.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.7.0
pycparser==2.20
pycryptodome==3.10.1
Pygments==2.10.0
pyparsing==2.4.7
PyPDF2==1.26.0
pyserial==3.5
python-bidi==0.4.2
python-crontab==2.5.1
python-dateutil==2.8.2
pytz==2021.1
PyYAML==5.4.1
qrcode==7.2
reedsolo==1.5.4
reportlab==3.6.1
requests==2.25.1
rsa==4.7.2
s3transfer==0.5.0
sentry-sdk==1.3.1
shortuuid==1.0.1
six==1.16.0
sqlparse==0.4.1
sympy==1.8
tablib==3.0.0
termcolor==1.1.0
toml==0.10.2
uritemplate==3.0.1
urllib3==1.26.2
uWSGI==2.0.19.1
vine==5.0.0
wcwidth==0.2.5
webencodings==0.5.1
wrapt==1.12.1
xhtml2pdf==0.2.5
xlrd==2.0.1
xlwt==1.3.0

Other Dependencies

N/A

Minimally Reproducible Test Case

Expected Behavior

I am using latest version of Celery 4 with RabbitMQ broker.

Recently I upgrade my RabbitMQ broker and started getting crashes, with following critical error in log:

Unrecoverable error: PreconditionFailed(406, 'PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more', (0, 0), '')

Doing some google searching lead me to a thread on RabbitMQ user group, this mentions that "ack timeout" was added from v3.8.15. This is new (unexpected) behaviour with the broker upgrade, earlier with v3.8.6 it did not happen.

Now is this known issue and fixed in Celery5 or is it new? I do not see any issues in the list regarding it.

Already posted this in celery-user group, but no response.

Actual Behavior

Proper ackhnowledgments should be sent before timeout that is causing crash.

Issue 2:
Checklist

I have verified that the issue exists against the master branch of Celery.

This has already been asked to the discussion group first.

I have read the relevant section in the

contribution guide

on reporting bugs.

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).

Mandatory Debugging Information

I have included the output of celery -A proj report in 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 master branch of Celery.

I have included the contents of pip freeze in the issue.

I have included all the versions of all the external dependencies required

to reproduce this bug.

Optional Debugging Information

I have tried reproducing the issue on more than one Python version

and/or implementation.

I have tried reproducing the issue on more than one message broker and/or

result backend.

I have tried reproducing the issue on more than one version of the message

broker and/or result backend.

I have tried reproducing the issue on more than one operating system.

I have tried reproducing the issue on more than one workers pool.

I have tried reproducing the issue with autoscaling, retries,

ETA/Countdown & rate limits disabled.

I have tried reproducing the issue after downgrading

and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

Retry not working properly when using chunks #6755

Pickling Retry instance is incorrect #6748

Possible Duplicates

None

Environment & Settings

Celery version: 5.0.5

celery report Output:

Steps to Reproduce

Create a django application with celery with default settings using pyamqp and rabbitmq 3.8.16 (current version) as broker, and run it in docker using docker-compose.

services:
rabbit:
container_name: rabbit
image: rabbitmq:3.8.16-management
hostname: myapp-rabbit
celery:
command: [
"bash", "-c", "date && celery -A myapp worker -l debug --scheduler django_celery_beat.schedulers:DatabaseScheduler -B"
]
image: <image based on ubuntu:20.04>
container_name: celery
depends_on:
- rabbit
- db
db:
image: postgres:10

Implement a task that will call retry, and then start everything and set up the scheduler to run the task.

@app.task(bind=True)
def debug_task(self):
print("Running debug task")
self.retry(countdown=60 * 60, max_retries=1)

Required Dependencies

Minimal Python Version: 3.8

Minimal Celery Version: 5.0.5

Minimal Kombu Version: 5.0.2

Minimal Broker Version: rabbit 3.8.16

Minimal Result Backend Version: N/A or Unknown

Minimal OS and/or Kernel Version: ubuntu 20.04

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

Django==3.1.5
amqp==5.0.6
celery==5.0.5
django-celery-beat==2.1.0
django-celery-results==2.0.1
kombu==5.0.2</summary>

Other Dependencies

N/A

Minimally Reproducible Test Case

Expected Behavior

Expected the task to retry after one hour

Actual Behavior

After 15 minutes, the entire celery container crashes with the following error

07/05/2021 06:51:38 MainProcess : celery.worker : CRITICAL Unrecoverable error: PreconditionFailed(406, 'PRECONDITION_FAILED - consumer ack timed out on channel 1', (0, 0), '')
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/celery/worker/worker.py", line 203, in start
self.blueprint.start(self)
File "/usr/local/lib/python3.8/dist-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/usr/local/lib/python3.8/dist-packages/celery/bootsteps.py", line 365, in start
return self.obj.start()
File "/usr/local/lib/python3.8/dist-packages/celery/worker/consumer/consumer.py", line 311, in start
blueprint.start(self)
File "/usr/local/lib/python3.8/dist-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/usr/local/lib/python3.8/dist-packages/celery/worker/consumer/consumer.py", line 592, in start
c.loop(*c.loop_args())
File "/usr/local/lib/python3.8/dist-packages/celery/worker/loops.py", line 81, in asynloop
next(loop)
File "/usr/local/lib/python3.8/dist-packages/kombu/asynchronous/hub.py", line 361, in create_loop
cb(*cbargs)
File "/usr/local/lib/python3.8/dist-packages/kombu/transport/base.py", line 235, in on_readable
reader(loop)
File "/usr/local/lib/python3.8/dist-packages/kombu/transport/base.py", line 217, in _read
drain_events(timeout=0)
File "/usr/local/lib/python3.8/dist-packages/amqp/connection.py", line 523, in drain_events
while not self.blocking_read(timeout):
File "/usr/local/lib/python3.8/dist-packages/amqp/connection.py", line 529, in blocking_read
return self.on_inbound_frame(frame)
File "/usr/local/lib/python3.8/dist-packages/amqp/method_framing.py", line 53, in on_frame
callback(channel, method_sig, buf, None)
File "/usr/local/lib/python3.8/dist-packages/amqp/connection.py", line 535, in on_inbound_method
return self.channels[channel_id].dispatch_method(
File "/usr/local/lib/python3.8/dist-packages/amqp/abstract_channel.py", line 143, in dispatch_method
listener(*args)
File "/usr/local/lib/python3.8/dist-packages/amqp/channel.py", line 277, in _on_close
raise error_for_code(
amqp.exceptions.PreconditionFailed: (0, 0): (406) PRECONDITION_FAILED - consumer ack timed out on channel 1

Rabbit logs the following:

[warning] <0.10196.1> Consumer None4 on channel 1 has timed out waiting on consumer acknowledgement. Timeout used: 900000 ms

Note that by downgrading rabbitmq to version 3.8.14 this doesn't happen anymore. (This might be a bug in rabbit instead.)