Issue 1:
I got weird problem with Celery. Shortly after start each pool worker dies with one of these two exception traces:

[2012-09-03 16:11:42,326: WARNING/MainProcess] Process PoolWorker-6:
[2012-09-03 16:11:42,326: WARNING/MainProcess] Traceback (most recent call last):
[2012-09-03 16:11:42,327: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/process.py", line 273, in _bootstrap
[2012-09-03 16:11:42,327: WARNING/MainProcess] self.run()
[2012-09-03 16:11:42,327: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/process.py", line 122, in run
[2012-09-03 16:11:42,327: WARNING/MainProcess] self._target(*self._args, **self._kwargs)
[2012-09-03 16:11:42,327: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/pool.py", line 302, in worker
[2012-09-03 16:11:42,328: WARNING/MainProcess] put((ACK, (job, i, time.time(), pid)))
[2012-09-03 16:11:42,328: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/queues.py", line 377, in put
[2012-09-03 16:11:42,329: WARNING/MainProcess] return send(obj)
[2012-09-03 16:11:42,329: WARNING/MainProcess] IOError: [Errno 32] Broken pipe

or

[2012-09-03 15:21:45,071: WARNING/MainProcess] Process PoolWorker-11:
[2012-09-03 15:21:45,072: WARNING/MainProcess] Traceback (most recent call last):
[2012-09-03 15:21:45,072: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/process.py", line 273, in _bootstrap
[2012-09-03 15:21:45,072: WARNING/MainProcess] self.run()
[2012-09-03 15:21:45,072: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/process.py", line 122, in run
[2012-09-03 15:21:45,072: WARNING/MainProcess] self._target(*self._args, **self._kwargs)
[2012-09-03 15:21:45,073: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/pool.py", line 314, in worker
[2012-09-03 15:21:45,073: WARNING/MainProcess] put((READY, (job, i, (False, einfo))))
[2012-09-03 15:21:45,073: WARNING/MainProcess] File "/mnt/nimble/eggs/billiard-2.7.3.12-py2.7-linux-x86_64.egg/billiard/queues.py", line 377, in put
[2012-09-03 15:21:45,073: WARNING/MainProcess] return send(obj)
[2012-09-03 15:21:45,073: WARNING/MainProcess] IOError: [Errno 32] Broken pipe

This problem disappears when launching Celery with --concurrency=1, but that's kind of poor workaround.

Celery report for my machine looks like this:

software -> celery:3.0.9 (Chiastic Slide) kombu:2.4.5 py:2.7.3
billiard:2.7.3.12 pymongo:2.1.1
platform -> system:Linux arch:64bit, ELF imp:CPython
loader -> celery.loaders.default.Loader
settings -> transport:mongodb results:mongodb

I was able to track the problem down to CELERYD_MAX_TASKS_PER_CHILD option in configuration file. After removing it Celery started working as expected. Looks like some multiprocessing issue with main process loosing track of rotating workers.

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

#2839

#4550

Possible Duplicates

None

Environment & Settings

Celery version:

celery report Output:

software -> celery:4.4.6 (cliffs) kombu:4.6.11 py:3.7.6
billiard:3.6.3.0 redis:3.5.3
platform -> system:Darwin arch:64bit
kernel version:19.6.0 imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:disabled

broker_url: 'redis://h:********@ec2-23-21-96-121.compute-1.amazonaws.com:24849//'
celery_backend_result: 'redis://h:********@ec2-23-21-96-121.compute-1.amazonaws.com:24849/'
task_acks_late: True
task_reject_on_worker_lost: True
task_time_limit: 300
broker_transport_options: {
'visibility_timeout': 3600}

Steps to Reproduce

Required Dependencies

Minimal Python Version: N/A or Unknown

Minimal Celery Version: N/A or Unknown

Minimal Kombu Version: N/A or Unknown

Minimal Broker Version: N/A or Unknown

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==2.6.0
appdirs==1.4.4
attrs==19.3.0
billiard==3.6.3.0
black==19.10b0
celery==4.4.6
click==7.1.2
flake8==3.8.3
future==0.18.2
importlib-metadata==1.7.0
kombu==4.6.11
mccabe==0.6.1
mypy==0.782
mypy-extensions==0.4.3
pathspec==0.8.0
pycodestyle==2.6.0
pyflakes==2.2.0
pytz==2020.1
redis==3.5.3
regex==2020.7.14
toml==0.10.1
typed-ast==1.4.1
typing-extensions==3.7.4.2
vine==1.3.0
zipp==3.1.0

Other Dependencies

N/A

Minimally Reproducible Test Case

I have reproduced it here: https://github.com/sayanarijit/remap-sigterm

Expected Behavior

https://github.com/sayanarijit/remap-sigterm#what-should-happen

The task is queued by redis.

Heroku worker starts executing the task which goes to a 5 min. sleep.

When shutdown, Heroku worker sends SIGQUIT (because REMAP_SIGTERM="SIGQUIT") to the worker.

The worker exists immediately never acknowledging the task (the task stays in queue).

After the worker comes back, it fetches the task from queue and starts running again.

Actual Behavior

https://github.com/sayanarijit/remap-sigterm#what-happens

The task is queued by redis.

Heroku worker starts executing the task which goes to a 5 min. sleep.

When shutdown, Heroku worker sends SIGTERM to the worker.

The worker waits for the process to exit.

After 30 seconds it kills the worker.

After the worker comes back, the queue is empty. Hence task is lost.