<h2 dir="auto">Checklist</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included the output of <code class="notranslate">celery -A proj report</code> in the issue.<br>
(if you are not able to do this, then at least specify the Celery<br>
version affected).</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="software -&gt; celery:4.2.1 (windowlicker) kombu:4.2.1 py:3.6.6
billiard:3.5.0.4 py-amqp:2.3.2
platform -&gt; system:Linux arch:64bit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:redis://XXXXXXXSNIPXXXXXXX

broker_url: 'amqp://XXXXXXXSNIPXXXXXXX'
task_ignore_result: False
worker_hijack_root_logger: False
result_backend: 'redis://XXXXXXXSNIPXXXXXXX'
task_acks_late: True
task_track_started: True
worker_prefetch_multiplier: 1
worker_pool_restarts: True
task_create_missing_queues: True"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.2.1 (windowlicker) kombu:4.2.1 py:3.6.6
billiard:3.5.0.4 py-amqp:2.3.2
platform -&gt; system:Linux arch:64bit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:redis://XXXXXXXSNIPXXXXXXX

broker_url: 'amqp://XXXXXXXSNIPXXXXXXX'
task_ignore_result: False
worker_hijack_root_logger: False
result_backend: 'redis://XXXXXXXSNIPXXXXXXX'
task_acks_late: True
task_track_started: True
worker_prefetch_multiplier: 1
worker_pool_restarts: True
task_create_missing_queues: True
</code></pre></div>
<p dir="auto">Worker info:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" -------------- celery@app v4.2.1 (windowlicker)
---- **** ----- 
--- * ***  * -- Linux-4.9.93-linuxkit-aufs-x86_64-with-debian-9.5 2018-08-24 15:19:01
-- * - **** --- 
- ** ---------- [config]
- ** ---------- .&gt; app:         XXXXXXXSNIPXXXXXXX
- ** ---------- .&gt; transport:   amqp://XXXXXXXSNIPXXXXXXX
- ** ---------- .&gt; results:     redis://XXXXXXXSNIPXXXXXXX
- *** --- * --- .&gt; concurrency: 2 (prefork)
-- ******* ---- .&gt; task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .&gt; celery           exchange=celery(direct) key=celery"><pre class="notranslate"><code class="notranslate"> -------------- celery@app v4.2.1 (windowlicker)
---- **** ----- 
--- * ***  * -- Linux-4.9.93-linuxkit-aufs-x86_64-with-debian-9.5 2018-08-24 15:19:01
-- * - **** --- 
- ** ---------- [config]
- ** ---------- .&gt; app:         XXXXXXXSNIPXXXXXXX
- ** ---------- .&gt; transport:   amqp://XXXXXXXSNIPXXXXXXX
- ** ---------- .&gt; results:     redis://XXXXXXXSNIPXXXXXXX
- *** --- * --- .&gt; concurrency: 2 (prefork)
-- ******* ---- .&gt; task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .&gt; celery           exchange=celery(direct) key=celery
</code></pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
</ul>
<p dir="auto">I have also verified that this issue exists as described on 4.1.1</p>
<h2 dir="auto">Steps to reproduce</h2>
<p dir="auto">Consider the following definition of a simple task, that waits for <code class="notranslate">delay</code> time, and then logs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import logging
from time import sleep
import celery

log = logging.getLogger(__name__)

@celery.shared_task(bind=True)
def test_task(self, *args, **kwargs):
    delay = kwargs.get('delay', 0)
    arg = args[-1]
    sleep(delay)
    log.info('Test Task called with %s', arg)"><pre class="notranslate"><code class="notranslate">import logging
from time import sleep
import celery

log = logging.getLogger(__name__)

@celery.shared_task(bind=True)
def test_task(self, *args, **kwargs):
    delay = kwargs.get('delay', 0)
    arg = args[-1]
    sleep(delay)
    log.info('Test Task called with %s', arg)
</code></pre></div>
<p dir="auto">Defer a task chain as follows, and then perform a warm shutdown of the workers</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="sigs = [test_task.s('A', delay=30), test_task.s('B'), test_task.s('C')]
celery.chain(sigs).apply_async()
sleep(20)
celery.current_app.control.shutdown() # this should occur during the execution of task A"><pre class="notranslate"><code class="notranslate">sigs = [test_task.s('A', delay=30), test_task.s('B'), test_task.s('C')]
celery.chain(sigs).apply_async()
sleep(20)
celery.current_app.control.shutdown() # this should occur during the execution of task A
</code></pre></div>
<p dir="auto">Finally, start the workers back up.</p>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">The worker gets a shutdown while running task A, and shuts down after completion of task A.<br>
Then, upon starting back up, the worker executes task B and finally task C.</p>
<h2 dir="auto">Actual behavior</h2>
<p dir="auto">The worker gets a shutdown while running task A, and shuts down after completion of task A.<br>
Upon starting back up, however, the worker executes both task B <em>and</em> task A again.  Furthermore, upon completion of task A, it then executes task B a second time, and so on with task C.  Essentially, from the point of restarting the worker, the entire task chain is duplicated.  Interestingly, the duplicate tasks throughout the entire chain appear to have duplicate ids (eg. task B runs with the same id both the first and second times).  Following are the worker logs demonstrating this behavior:</p>
<p dir="auto">The initial worker run</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[15:29:02] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[106]:150 task_prerun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f66b74036d8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}}
[15:29:22] WARNING  celery.worker.control[100]:519 Got shutdown from remote
[15:29:22] INFO  foobar_project.celery[105]:150 worker_process_shutdown: {'pid': 105, 'exitcode': 0}
[15:29:32] INFO 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar.tasks.test[106]:13 Test Task called with A
[15:29:32] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[106]:150 task_postrun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f66b74036d8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}, 'retval': None, 'state': 'SUCCESS'}
[15:29:32] INFO 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[106]:150 worker_process_shutdown: {'pid': 106, 'exitcode': 0}
[15:29:33] INFO  foobar_project.celery[100]:152 worker_shutdown"><pre class="notranslate"><code class="notranslate">[15:29:02] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[106]:150 task_prerun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f66b74036d8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}}
[15:29:22] WARNING  celery.worker.control[100]:519 Got shutdown from remote
[15:29:22] INFO  foobar_project.celery[105]:150 worker_process_shutdown: {'pid': 105, 'exitcode': 0}
[15:29:32] INFO 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar.tasks.test[106]:13 Test Task called with A
[15:29:32] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[106]:150 task_postrun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f66b74036d8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}, 'retval': None, 'state': 'SUCCESS'}
[15:29:32] INFO 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[106]:150 worker_process_shutdown: {'pid': 106, 'exitcode': 0}
[15:29:33] INFO  foobar_project.celery[100]:152 worker_shutdown
</code></pre></div>
<p dir="auto">The worker logs after the worker is restarted</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[15:30:07] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[122]:150 task_prerun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}}
[15:30:07] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[123]:150 task_prerun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}}
[15:30:07] INFO 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar.tasks.test[122]:13 Test Task called with B
[15:30:07] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[122]:150 task_postrun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
[15:30:07] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[122]:150 task_prerun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}}
[15:30:07] INFO e5a39e30-0345-43f0-857f-ad05e2111abc foobar.tasks.test[122]:13 Test Task called with C
[15:30:07] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[122]:150 task_postrun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
[15:30:37] INFO 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar.tasks.test[123]:13 Test Task called with A
[15:30:37] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[123]:150 task_postrun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}, 'retval': None, 'state': 'SUCCESS'}
[15:30:37] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[123]:150 task_prerun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}}
[15:30:37] INFO 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar.tasks.test[123]:13 Test Task called with B
[15:30:37] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[123]:150 task_postrun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
[15:30:37] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[123]:150 task_prerun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}}
[15:30:37] INFO e5a39e30-0345-43f0-857f-ad05e2111abc foobar.tasks.test[123]:13 Test Task called with C
[15:30:37] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[123]:150 task_postrun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}"><pre class="notranslate"><code class="notranslate">[15:30:07] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[122]:150 task_prerun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}}
[15:30:07] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[123]:150 task_prerun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}}
[15:30:07] INFO 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar.tasks.test[122]:13 Test Task called with B
[15:30:07] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[122]:150 task_postrun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
[15:30:07] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[122]:150 task_prerun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}}
[15:30:07] INFO e5a39e30-0345-43f0-857f-ad05e2111abc foobar.tasks.test[122]:13 Test Task called with C
[15:30:07] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[122]:150 task_postrun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
[15:30:37] INFO 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar.tasks.test[123]:13 Test Task called with A
[15:30:37] DEBUG 7d841ca8-c2a6-40e1-8022-a4e370e79861 foobar_project.celery[123]:150 task_postrun: {'task_id': '7d841ca8-c2a6-40e1-8022-a4e370e79861', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': ['A'], 'kwargs': {'delay': 30}, 'retval': None, 'state': 'SUCCESS'}
[15:30:37] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[123]:150 task_prerun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}}
[15:30:37] INFO 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar.tasks.test[123]:13 Test Task called with B
[15:30:37] DEBUG 2922b5cf-6f52-415d-b2b9-4713b92388ab foobar_project.celery[123]:150 task_postrun: {'task_id': '2922b5cf-6f52-415d-b2b9-4713b92388ab', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'B'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
[15:30:37] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[123]:150 task_prerun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}}
[15:30:37] INFO e5a39e30-0345-43f0-857f-ad05e2111abc foobar.tasks.test[123]:13 Test Task called with C
[15:30:37] DEBUG e5a39e30-0345-43f0-857f-ad05e2111abc foobar_project.celery[123]:150 task_postrun: {'task_id': 'e5a39e30-0345-43f0-857f-ad05e2111abc', 'task': &lt;@task: foobar.tasks.test.test_task of foobar_project at 0x7f31212fadd8&gt;, 'args': [None, 'C'], 'kwargs': {}, 'retval': None, 'state': 'SUCCESS'}
</code></pre></div>
<p dir="auto">As one might imagine, this behavior makes running chains of tasks that require a particular ordering difficult.</p>
<h2 dir="auto">Other notes</h2>
<p dir="auto">I originally observed this behavior with a task that was retrying (via <code class="notranslate">self.retry</code>), so the behavior does not appear to be related to the task state being <code class="notranslate">SUCCESS</code> (or at least is also present with state=<code class="notranslate">RETRY</code>).  I provided this non-retrying case as it is a simpler example.</p>
<p dir="auto">This issue is very likely related to both/either <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="203444855" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/3796" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/3796/hovercard" href="https://github.com/celery/celery/issues/3796">#3796</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="204173315" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/3802" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/3802/hovercard" href="https://github.com/celery/celery/issues/3802">#3802</a> ; I have submitted this issue separately to highlight the behavior of the task chains with duplicate ids, as well as the behavior with <code class="notranslate">RETRY</code> rather than <code class="notranslate">SUCCESS</code>.  Only workaround I've found thus far is to use a lock on <code class="notranslate">task_id</code> to detect the duplication, and then kill the "second" task (whichever failed to get the lock) by raising an Exception.  This still has the unfortunate drawback of calling into any link_error handlers on the chain.</p>
<h1 dir="auto">Checklist</h1>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> This has already been asked to the <a href="https://groups.google.com/forum/#!forum/celery-users" rel="nofollow">discussion group</a> first.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the relevant section in the<br>
<a href="http://docs.celeryproject.org/en/latest/contributing.html#other-bugs" rel="nofollow">contribution guide</a><br>
on reporting bugs.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22">issues list</a><br>
for similar or identical bug reports.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed fixes.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/commits/master">commit log</a><br>
to find out if the bug was already fixed in the master branch.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included all related issues and possible duplicate issues<br>
in this issue (If there are none, check this box anyway).</li>
</ul>
<h2 dir="auto">Mandatory Debugging Information</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included the output of <code class="notranslate">celery -A proj report</code> in the issue.<br>
(if you are not able to do this, then at least specify the Celery<br>
version affected).</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included the contents of <code class="notranslate">pip freeze</code> in the issue.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have included all the versions of all the external dependencies required<br>
to reproduce this bug.</li>
</ul>
<h2 dir="auto">Optional Debugging Information</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one Python version<br>
and/or implementation.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one message broker and/or<br>
result backend.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one version of the message<br>
broker and/or result backend.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one operating system.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one workers pool.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue with autoscaling, retries,<br>
ETA/Countdown &amp; rate limits disabled.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue after downgrading<br>
and/or upgrading Celery and its dependencies.</li>
</ul>
<h2 dir="auto">Related Issues and Possible Duplicates</h2>

<h4 dir="auto">Related Issues</h4>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="628336284" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/6134" data-hovercard-type="pull_request" data-hovercard-url="/celery/celery/pull/6134/hovercard" href="https://github.com/celery/celery/pull/6134">#6134</a></li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="239866650" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/4116" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/4116/hovercard" href="https://github.com/celery/celery/issues/4116">#4116</a></li>
</ul>
<h2 dir="auto">Environment &amp; Settings</h2>

<p dir="auto"><strong>Celery version</strong>:<br>
today master: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/celery/celery/commit/39209f2db2021eb0b685603ae4b6d0e3a5894849/hovercard" href="https://github.com/celery/celery/commit/39209f2db2021eb0b685603ae4b6d0e3a5894849"><tt>39209f2</tt></a></p>

<details>
<summary><b><code class="notranslate">celery report</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate"></code></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Steps to Reproduce</h1>
<h2 dir="auto">Required Dependencies</h2>

<ul dir="auto">
<li><strong>Minimal Python Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Celery Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Kombu Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Result Backend Version</strong>: N/A or Unknown</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Client Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Result Backend Client Version</strong>: N/A or Unknown</li>
</ul>
<h3 dir="auto">Python Packages</h3>

<details>
<summary><b><code class="notranslate">pip freeze</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate"></code></pre></div>
<p dir="auto"></p>
</details>
<h3 dir="auto">Other Dependencies</h3>

<details>
<p dir="auto">
N/A
</p>
</details>
<h2 dir="auto">Minimally Reproducible Test Case</h2>

<details>
<p dir="auto">
</p><div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/celery/celery/blob/39209f2db2021eb0b685603ae4b6d0e3a5894849/celery/fixups/django.py#L180">celery/celery/fixups/django.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 180
      in
      <a data-pjax="true" class="commit-tease-sha" href="/celery/celery/commit/39209f2db2021eb0b685603ae4b6d0e3a5894849">39209f2</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L180" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="180"></td>
          <td id="LC180" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">self</span>.<span class="pl-en">_close_database</span>() </td>
        </tr>
    </tbody></table>
  </div>
</div>
<br>
Here maybe it should be <code class="notranslate">_close_database(force=True)</code>, following <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="628336284" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/6134" data-hovercard-type="pull_request" data-hovercard-url="/celery/celery/pull/6134/hovercard" href="https://github.com/celery/celery/pull/6134">#6134</a>: when celery db max reuse is reached we probably do want to really close everything and not ask django to maybe close them according to django settings.<p></p>
<h1 dir="auto">Actual Behavior</h1>