<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"> 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" 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>
<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="826311180" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/6672" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/6672/hovercard" href="https://github.com/celery/celery/issues/6672">#6672</a></li>
</ul>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h2 dir="auto">Environment &amp; Settings</h2>

<p dir="auto"><strong>Celery version</strong>:  5.1.2</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="software -&gt; celery:5.1.2 (sun-harmonics) kombu:5.1.0 py:3.6.8
            billiard:3.6.4.0 py-amqp:5.0.6
platform -&gt; system:Darwin arch:64bit
            kernel version:20.5.0 imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:django-db

accept_content: ['pickle']
result_serializer: 'pickle'
task_serializer: 'pickle'"><pre class="notranslate"><code class="notranslate">software -&gt; celery:5.1.2 (sun-harmonics) kombu:5.1.0 py:3.6.8
            billiard:3.6.4.0 py-amqp:5.0.6
platform -&gt; system:Darwin arch:64bit
            kernel version:20.5.0 imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:django-db

accept_content: ['pickle']
result_serializer: 'pickle'
task_serializer: 'pickle'
</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>
Prerequirements are to have the Django project and setup described in official celery docs.
<p dir="auto">
</p><div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@app.task
def sleep_task(user_object):
    import time
    time.sleep(100000)

# in Django shell
sleep_task.delay(User.objects.first())"><pre class="notranslate"><span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-s1">task</span></span>
<span class="pl-k">def</span> <span class="pl-en">sleep_task</span>(<span class="pl-s1">user_object</span>):
    <span class="pl-k">import</span> <span class="pl-s1">time</span>
    <span class="pl-s1">time</span>.<span class="pl-en">sleep</span>(<span class="pl-c1">100000</span>)

<span class="pl-c"># in Django shell</span>
<span class="pl-s1">sleep_task</span>.<span class="pl-en">delay</span>(<span class="pl-v">User</span>.<span class="pl-s1">objects</span>.<span class="pl-en">first</span>())</pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>

<p dir="auto">We should have standard inspect active output with deserialized Django object like in 4.x.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="-&gt;  celery@xyz: OK
    * {'id': '81f641db-8ba9-45c8-8d1e-e8cd52c50de1', 'name': 'proj.tasks.sleep_task', 'args': (&lt;User: XYZ&gt;,), 'kwargs': {}, 'type': 'proj.tasks.sleep_task'', 'hostname': 'celery@xyz', 'time_start': 1633008451.4256349, 'acknowledged': True, 'delivery_info': {'exchange': '', 'routing_key': 'celery', 'priority': 0, 'redelivered': False}, 'worker_pid': 36039}

1 node online."><pre class="notranslate"><code class="notranslate">-&gt;  celery@xyz: OK
    * {'id': '81f641db-8ba9-45c8-8d1e-e8cd52c50de1', 'name': 'proj.tasks.sleep_task', 'args': (&lt;User: XYZ&gt;,), 'kwargs': {}, 'type': 'proj.tasks.sleep_task'', 'hostname': 'celery@xyz', 'time_start': 1633008451.4256349, 'acknowledged': True, 'delivery_info': {'exchange': '', 'routing_key': 'celery', 'priority': 0, 'redelivered': False}, 'worker_pid': 36039}

1 node online.
</code></pre></div>
<h1 dir="auto">Actual Behavior</h1>

<p dir="auto">Instead of receiving the active task data, <code class="notranslate">celery -A proj inspect active</code> raises DecodeError</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 42, in _reraise_errors
    yield
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 255, in loads
    return decode(data)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 327, in unpickle
    return pickle_loads(str_to_bytes(s))
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 51, in pickle_loads
    return load(BytesIO(s))
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/db/models/base.py&quot;, line 1828, in model_unpickle
    model = apps.get_model(*model_id)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py&quot;, line 198, in get_model
    self.check_models_ready()
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py&quot;, line 140, in check_models_ready
    raise AppRegistryNotReady(&quot;Models aren't loaded yet.&quot;)
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;/Users/xyz/.virtualenvs/proj/bin/celery&quot;, line 8, in &lt;module&gt;
    sys.exit(main())
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/__main__.py&quot;, line 15, in main
    sys.exit(_main())
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/bin/celery.py&quot;, line 213, in main
    return celery(auto_envvar_prefix=&quot;CELERY&quot;)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py&quot;, line 829, in __call__
    return self.main(*args, **kwargs)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py&quot;, line 782, in main
    rv = self.invoke(ctx)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py&quot;, line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py&quot;, line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py&quot;, line 610, in invoke
    return callback(*args, **kwargs)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/decorators.py&quot;, line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/bin/base.py&quot;, line 133, in caller
    return f(ctx, *args, **kwargs)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/bin/control.py&quot;, line 137, in inspect
    **arguments)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/app/control.py&quot;, line 114, in _request
    pattern=self.pattern, matcher=self.matcher,
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/app/control.py&quot;, line 743, in broadcast
    limit, callback, channel=channel,
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/pidbox.py&quot;, line 350, in _broadcast
    channel=chan)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/pidbox.py&quot;, line 389, in _collect
    self.connection.drain_events(timeout=timeout)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/connection.py&quot;, line 318, in drain_events
    return self.transport.drain_events(self.connection, **kwargs)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/transport/pyamqp.py&quot;, line 135, in drain_events
    return connection.drain_events(**kwargs)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/connection.py&quot;, line 523, in drain_events
    while not self.blocking_read(timeout):
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/connection.py&quot;, line 529, in blocking_read
    return self.on_inbound_frame(frame)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/method_framing.py&quot;, line 77, in on_frame
    callback(channel, msg.frame_method, msg.frame_args, msg)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/connection.py&quot;, line 536, in on_inbound_method
    method_sig, payload, content,
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/abstract_channel.py&quot;, line 143, in dispatch_method
    listener(*args)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/channel.py&quot;, line 1613, in _on_basic_deliver
    fun(msg)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/messaging.py&quot;, line 620, in _receive_callback
    decoded = None if on_m else message.decode()
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/message.py&quot;, line 190, in decode
    self._decoded_cache = self._decode()
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/message.py&quot;, line 195, in _decode
    self.content_encoding, accept=self.accept)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 255, in loads
    return decode(data)
  File &quot;/Users/xyz/.pyenv/versions/3.6.8/lib/python3.6/contextlib.py&quot;, line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 46, in _reraise_errors
    reraise(wrapper, wrapper(exc), sys.exc_info()[2])
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/exceptions.py&quot;, line 21, in reraise
    raise value.with_traceback(tb)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 42, in _reraise_errors
    yield
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 255, in loads
    return decode(data)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 327, in unpickle
    return pickle_loads(str_to_bytes(s))
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py&quot;, line 51, in pickle_loads
    return load(BytesIO(s))
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/db/models/base.py&quot;, line 1828, in model_unpickle
    model = apps.get_model(*model_id)
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py&quot;, line 198, in get_model
    self.check_models_ready()
  File &quot;/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py&quot;, line 140, in check_models_ready
    raise AppRegistryNotReady(&quot;Models aren't loaded yet.&quot;)
kombu.exceptions.DecodeError: Models aren't loaded yet."><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 42, in _reraise_errors
    yield
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 255, in loads
    return decode(data)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 327, in unpickle
    return pickle_loads(str_to_bytes(s))
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 51, in pickle_loads
    return load(BytesIO(s))
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/db/models/base.py", line 1828, in model_unpickle
    model = apps.get_model(*model_id)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py", line 198, in get_model
    self.check_models_ready()
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py", line 140, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/xyz/.virtualenvs/proj/bin/celery", line 8, in &lt;module&gt;
    sys.exit(main())
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/__main__.py", line 15, in main
    sys.exit(_main())
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/bin/celery.py", line 213, in main
    return celery(auto_envvar_prefix="CELERY")
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/bin/base.py", line 133, in caller
    return f(ctx, *args, **kwargs)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/bin/control.py", line 137, in inspect
    **arguments)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/app/control.py", line 114, in _request
    pattern=self.pattern, matcher=self.matcher,
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/celery/app/control.py", line 743, in broadcast
    limit, callback, channel=channel,
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/pidbox.py", line 350, in _broadcast
    channel=chan)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/pidbox.py", line 389, in _collect
    self.connection.drain_events(timeout=timeout)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/connection.py", line 318, in drain_events
    return self.transport.drain_events(self.connection, **kwargs)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 135, in drain_events
    return connection.drain_events(**kwargs)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/connection.py", line 523, in drain_events
    while not self.blocking_read(timeout):
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/connection.py", line 529, in blocking_read
    return self.on_inbound_frame(frame)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/method_framing.py", line 77, in on_frame
    callback(channel, msg.frame_method, msg.frame_args, msg)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/connection.py", line 536, in on_inbound_method
    method_sig, payload, content,
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/abstract_channel.py", line 143, in dispatch_method
    listener(*args)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/amqp/channel.py", line 1613, in _on_basic_deliver
    fun(msg)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/messaging.py", line 620, in _receive_callback
    decoded = None if on_m else message.decode()
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/message.py", line 190, in decode
    self._decoded_cache = self._decode()
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/message.py", line 195, in _decode
    self.content_encoding, accept=self.accept)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 255, in loads
    return decode(data)
  File "/Users/xyz/.pyenv/versions/3.6.8/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 46, in _reraise_errors
    reraise(wrapper, wrapper(exc), sys.exc_info()[2])
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/exceptions.py", line 21, in reraise
    raise value.with_traceback(tb)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 42, in _reraise_errors
    yield
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 255, in loads
    return decode(data)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 327, in unpickle
    return pickle_loads(str_to_bytes(s))
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/kombu/serialization.py", line 51, in pickle_loads
    return load(BytesIO(s))
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/db/models/base.py", line 1828, in model_unpickle
    model = apps.get_model(*model_id)
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py", line 198, in get_model
    self.check_models_ready()
  File "/Users/xyz/.virtualenvs/proj/lib/python3.6/site-packages/django/apps/registry.py", line 140, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
kombu.exceptions.DecodeError: Models aren't loaded yet.
</code></pre></div>
<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"> 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" checked=""> 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" 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>
<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" checked=""> 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" checked=""> 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>None</li>
</ul>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h2 dir="auto">Environment &amp; Settings</h2>

<p dir="auto"><strong>Celery version</strong>:</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="software -&gt; celery:4.2.1 (windowlicker) kombu:4.6.7 py:3.6.5
            billiard:3.5.0.5 sqs:N/A
platform -&gt; system:Darwin arch:64bit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:sqs results:disabled

BROKER_TRANSPORT_OPTIONS: {
    'polling_interval': 1,
    'queue_name_prefix': 'celery_dev-',
    'region': 'eu-west-1',
    'sqs-creation-attributes': {'KmsMasterKeyId': '********'},
    'visibility_timeout': 3600,
    'wait_time_seconds': 10}
BROKER_URL: 'sqs://localhost//'
CELERYBEAT_SCHEDULE: {***}
CELERYD_LOG_FORMAT: ('%(asctime)s %(name)s '
 '%(process)d-0@local '
 '[%(levelname)s] %(pathname)s:%(lineno)d '
 '%(funcName)s(): %(module)s: %(message)s')
CELERY_ACKS_LATE: True
CELERY_ENABLE_REMOTE_CONTROL: False
CELERY_ENABLE_UTC: True
CELERY_SEND_EVENTS: False
CELERY_TIMEZONE: 'Asia/Kolkata'
DEBUG: True
DEFAULT_VISIBILITY_TIMEOUT: 3600
REGION_NAME: 'eu-west-1'
USE_API_AUTH: '********'
crontab: &lt;class 'celery.schedules.crontab'&gt;
env: 'dev'
gethostname: &lt;built-in function gethostname&gt;
CELERY_INCLUDE: ['tasks.generic_tasks']"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.2.1 (windowlicker) kombu:4.6.7 py:3.6.5
            billiard:3.5.0.5 sqs:N/A
platform -&gt; system:Darwin arch:64bit imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:sqs results:disabled

BROKER_TRANSPORT_OPTIONS: {
    'polling_interval': 1,
    'queue_name_prefix': 'celery_dev-',
    'region': 'eu-west-1',
    'sqs-creation-attributes': {'KmsMasterKeyId': '********'},
    'visibility_timeout': 3600,
    'wait_time_seconds': 10}
BROKER_URL: 'sqs://localhost//'
CELERYBEAT_SCHEDULE: {***}
CELERYD_LOG_FORMAT: ('%(asctime)s %(name)s '
 '%(process)d-0@local '
 '[%(levelname)s] %(pathname)s:%(lineno)d '
 '%(funcName)s(): %(module)s: %(message)s')
CELERY_ACKS_LATE: True
CELERY_ENABLE_REMOTE_CONTROL: False
CELERY_ENABLE_UTC: True
CELERY_SEND_EVENTS: False
CELERY_TIMEZONE: 'Asia/Kolkata'
DEBUG: True
DEFAULT_VISIBILITY_TIMEOUT: 3600
REGION_NAME: 'eu-west-1'
USE_API_AUTH: '********'
crontab: &lt;class 'celery.schedules.crontab'&gt;
env: 'dev'
gethostname: &lt;built-in function gethostname&gt;
CELERY_INCLUDE: ['tasks.generic_tasks']
</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>: Python 3.6.5</li>
<li><strong>Minimal Celery Version</strong>: 4.2.1</li>
<li><strong>Minimal Kombu Version</strong>: 4.6.7</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="amqp==2.5.2
aws-requests-auth==0.4.2
awscli==1.16.53
billiard==3.5.0.5
boto3==1.9.161
botocore==1.12.182
celery==4.2.1
certifi==2019.11.28
chardet==3.0.4
circus==0.15.0
click==6.7
colorama==0.3.9
docutils==0.14
elasticsearch==6.2.0
elasticsearch-curator==5.8.0
flasgger==0.9.2
Flask==1.0.2
gunicorn==19.9.0
idna==2.7
importlib-metadata==1.3.0
itsdangerous==1.1.0
Jinja2==2.10
jmespath==0.9.3
jsonpickle==1.0
jsonschema==2.6.0
kombu==4.6.7
MarkupSafe==1.0
mistune==0.8.4
more-itertools==8.0.2
mysqlclient==1.3.13
psutil==5.4.8
pyasn1==0.4.4
pycurl==7.43.0.1
python-dateutil==2.7.5
pytz==2018.7
PyYAML==3.13
pyzmq==16.0.4
redis==2.10.6
requests==2.19.1
requests-aws4auth==0.9
rsa==3.4.2
s3transfer==0.2.1
six==1.11.0
SQLAlchemy==1.2.14
tornado==4.5.3
urllib3==1.22
vine==1.3.0
voluptuous==0.11.7
Werkzeug==0.14.1
zipp==0.6.0"><pre class="notranslate"><code class="notranslate">amqp==2.5.2
aws-requests-auth==0.4.2
awscli==1.16.53
billiard==3.5.0.5
boto3==1.9.161
botocore==1.12.182
celery==4.2.1
certifi==2019.11.28
chardet==3.0.4
circus==0.15.0
click==6.7
colorama==0.3.9
docutils==0.14
elasticsearch==6.2.0
elasticsearch-curator==5.8.0
flasgger==0.9.2
Flask==1.0.2
gunicorn==19.9.0
idna==2.7
importlib-metadata==1.3.0
itsdangerous==1.1.0
Jinja2==2.10
jmespath==0.9.3
jsonpickle==1.0
jsonschema==2.6.0
kombu==4.6.7
MarkupSafe==1.0
mistune==0.8.4
more-itertools==8.0.2
mysqlclient==1.3.13
psutil==5.4.8
pyasn1==0.4.4
pycurl==7.43.0.1
python-dateutil==2.7.5
pytz==2018.7
PyYAML==3.13
pyzmq==16.0.4
redis==2.10.6
requests==2.19.1
requests-aws4auth==0.9
rsa==3.4.2
s3transfer==0.2.1
six==1.11.0
SQLAlchemy==1.2.14
tornado==4.5.3
urllib3==1.22
vine==1.3.0
voluptuous==0.11.7
Werkzeug==0.14.1
zipp==0.6.0
</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">
Obtained this issue once in production
</p>
</details>
<h1 dir="auto">Expected Behavior</h1>

<p dir="auto">Task should be processed by other available consumers</p>
<h1 dir="auto">Actual Behavior</h1>

<h2 dir="auto">Context</h2>
<ul dir="auto">
<li>We have 3 machines in prod for celery workers and have a one-by-one deployment strategy. Hence, at any time, we have 2 workers available to pick up tasks</li>
<li>As mentioned above, the visibility timeout is kept 1 hr</li>
<li>We have one task which is triggered by 2 crons. One cron @ 5th, 35th and 50th minute of every hour. Another @ 20th minute. (The difference is in parameters passed to the task)</li>
</ul>
<h2 dir="auto">Issue</h2>
<ul dir="auto">
<li>Around 9:20 PM, we had a deployment for the celery worker machines. The beat machine was deployed later.</li>
<li>A task, T1, was scheduled successfully. Verified by the "Sending due task" logs from beat machine</li>
<li>Ideally within a few seconds, the task is picked up by the worker machines, but no logs are found. I checked the logs of "Received task"</li>
<li>Around 10:20 PM, beat schedules another task (T2). Verified by the "Sending due task" logs from beat machine</li>
<li>This time, we see the "Received task" logs twice.</li>
<li>Verified that they are not the same task "instance" by comparing the task ids. This also rules out the possibility that SQS gave double delivery (at least once effort)</li>
</ul>
<h2 dir="auto">Hypothesis</h2>
<p dir="auto">The task, T1, was received by the master process in one machine. This triggered the visibility timer at SQS. The task was not yet passed to the worker threads. During sigterm, the task was not restored to SQS and thus, after the visibility timeout = 1 hr, the task got picked up and executed</p>
<h2 dir="auto">Callouts</h2>
<ul dir="auto">
<li>This issue has occurred once as per our knowledge (I discovered this while root causing another issue). Thus, unsure if this is happening already multiple times but not getting caught.</li>
<li>Unable to reproduce this on local / beta machines</li>
</ul>
<h2 dir="auto">Expectation from the community</h2>
<ol dir="auto">
<li>Does the hypothesis imply the issue?</li>
<li>Any ideas on how to reproduce such a condition successfully?</li>
<li>What logs would be better to switch on at celery side so that we can catch this issue next time it happens. (We can't possibly move to debug level because the sheer volume is too high)</li>
</ol>