<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" 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" 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" 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"> 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.4.3 (cliffs) kombu:4.6.9 py:3.7.6
            billiard:3.6.3.0 py-amqp:2.6.0
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:4.15.0-101-generic imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:cassandra

Queue: &lt;class 'kombu.entity.Queue'&gt;
RoundRobinPolicy: &lt;class 'cassandra.policies.RoundRobinPolicy'&gt;
broker_url: 'amqp://guest:********@localhost:5672//'
cassandra_auth_kwargs: {
 'password': '********', 'username': 'cassandra'}
cassandra_auth_provider: 'PlainTextAuthProvider'
cassandra_entry_ttl: 86400
cassandra_keyspace: '********'
cassandra_options: {
    'load_balancing_policy': &lt;cassandra.policies.RoundRobinPolicy object at 0x7f09de9a34d0&gt;}
cassandra_servers: ['127.0.0.1']
cassandra_table: 'celery_jobs_result'
ignore_result: False
result_backend: 'cassandra'
worker_concurrency: 4"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.4.3 (cliffs) kombu:4.6.9 py:3.7.6
            billiard:3.6.3.0 py-amqp:2.6.0
platform -&gt; system:Linux arch:64bit, ELF
            kernel version:4.15.0-101-generic imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:cassandra

Queue: &lt;class 'kombu.entity.Queue'&gt;
RoundRobinPolicy: &lt;class 'cassandra.policies.RoundRobinPolicy'&gt;
broker_url: 'amqp://guest:********@localhost:5672//'
cassandra_auth_kwargs: {
 'password': '********', 'username': 'cassandra'}
cassandra_auth_provider: 'PlainTextAuthProvider'
cassandra_entry_ttl: 86400
cassandra_keyspace: '********'
cassandra_options: {
    'load_balancing_policy': &lt;cassandra.policies.RoundRobinPolicy object at 0x7f09de9a34d0&gt;}
cassandra_servers: ['127.0.0.1']
cassandra_table: 'celery_jobs_result'
ignore_result: False
result_backend: 'cassandra'
worker_concurrency: 4
</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="amqp==2.6.0
attrs==19.3.0
billiard==3.6.3.0
case==1.5.3
cassandra-driver==3.20.2
future==0.18.2
gevent==20.5.2
greenlet==0.4.15
importlib-metadata==1.6.0
kombu==4.6.9
linecache2==1.0.0
mock==4.0.2
more-itertools==8.3.0
nose==1.3.7
packaging==20.4
pluggy==0.13.1
py==1.8.1
pyparsing==2.4.7
pytest==5.4.2
pytz==2020.1
redis==3.5.2
six==1.15.0
traceback2==1.4.0
unittest2==1.1.0
vine==1.3.0
wcwidth==0.1.9
zipp==3.1.0
zope.event==4.4
zope.interface==5.1.0"><pre class="notranslate"><code class="notranslate">amqp==2.6.0
attrs==19.3.0
billiard==3.6.3.0
case==1.5.3
cassandra-driver==3.20.2
future==0.18.2
gevent==20.5.2
greenlet==0.4.15
importlib-metadata==1.6.0
kombu==4.6.9
linecache2==1.0.0
mock==4.0.2
more-itertools==8.3.0
nose==1.3.7
packaging==20.4
pluggy==0.13.1
py==1.8.1
pyparsing==2.4.7
pytest==5.4.2
pytz==2020.1
redis==3.5.2
six==1.15.0
traceback2==1.4.0
unittest2==1.1.0
vine==1.3.0
wcwidth==0.1.9
zipp==3.1.0
zope.event==4.4
zope.interface==5.1.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">
</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">CassandraBackend work fine</p>
<h1 dir="auto">Actual Behavior</h1>
<h2 dir="auto">in prefork pool or solo:</h2>
<p dir="auto">it can work, just not good, i think</p>
<h2 dir="auto">in threads or gevent pool:</h2>
<p dir="auto">get these error frequently</p>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2020-06-02 21:52:19,592: ERROR/MainProcess] Task add[4bd528a0-c1ba-456c-b74e-7dee054616bb] raised unexpected: AttributeError(&quot;'NoneType' object has no attribute 'execute'&quot;)
Traceback (most recent call last):
  File &quot;/home/bx/project/celery/celery/app/trace.py&quot;, line 480, in trace_task
    uuid, retval, task_request, publish_result,
  File &quot;/home/bx/project/celery/celery/backends/base.py&quot;, line 158, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File &quot;/home/bx/project/celery/celery/backends/base.py&quot;, line 443, in store_result
    request=request, **kwargs)
  File &quot;/home/bx/project/celery/celery/backends/cassandra.py&quot;, line 201, in _store_result
    self._session.execute(self._write_stmt, (
AttributeError: 'NoneType' object has no attribute 'execute'"><pre class="notranslate"><code class="notranslate">[2020-06-02 21:52:19,592: ERROR/MainProcess] Task add[4bd528a0-c1ba-456c-b74e-7dee054616bb] raised unexpected: AttributeError("'NoneType' object has no attribute 'execute'")
Traceback (most recent call last):
  File "/home/bx/project/celery/celery/app/trace.py", line 480, in trace_task
    uuid, retval, task_request, publish_result,
  File "/home/bx/project/celery/celery/backends/base.py", line 158, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File "/home/bx/project/celery/celery/backends/base.py", line 443, in store_result
    request=request, **kwargs)
  File "/home/bx/project/celery/celery/backends/cassandra.py", line 201, in _store_result
    self._session.execute(self._write_stmt, (
AttributeError: 'NoneType' object has no attribute 'execute'
</code></pre></div>
<p dir="auto">
</p><p dir="auto">and</p>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2020-06-02 21:52:29,773: ERROR/MainProcess] Task add[27c980d3-126a-430d-a8e0-92d749ceb735] raised unexpected: OperationTimedOut(&quot;errors=errors={'Connection defunct by heartbeat': 'Client request timeout. See Session.execute[_async](timeout)'}, last_host=127.0.0.1:9042, last_host=None&quot;)
Traceback (most recent call last):
  File &quot;/home/bx/project/celery/celery/app/trace.py&quot;, line 480, in trace_task
    uuid, retval, task_request, publish_result,
  File &quot;/home/bx/project/celery/celery/backends/base.py&quot;, line 158, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File &quot;/home/bx/project/celery/celery/backends/base.py&quot;, line 443, in store_result
    request=request, **kwargs)
  File &quot;/home/bx/project/celery/celery/backends/cassandra.py&quot;, line 207, in _store_result
    buf_t(self.encode(self.current_task_children(request)))
  File &quot;cassandra/cluster.py&quot;, line 2345, in cassandra.cluster.Session.execute
  File &quot;cassandra/cluster.py&quot;, line 4304, in cassandra.cluster.ResponseFuture.result
cassandra.OperationTimedOut: errors=errors={'Connection defunct by heartbeat': 'Client request timeout. See Session.execute[_async](timeout)'}, last_host=127.0.0.1:9042, last_host=None"><pre class="notranslate"><code class="notranslate">[2020-06-02 21:52:29,773: ERROR/MainProcess] Task add[27c980d3-126a-430d-a8e0-92d749ceb735] raised unexpected: OperationTimedOut("errors=errors={'Connection defunct by heartbeat': 'Client request timeout. See Session.execute[_async](timeout)'}, last_host=127.0.0.1:9042, last_host=None")
Traceback (most recent call last):
  File "/home/bx/project/celery/celery/app/trace.py", line 480, in trace_task
    uuid, retval, task_request, publish_result,
  File "/home/bx/project/celery/celery/backends/base.py", line 158, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File "/home/bx/project/celery/celery/backends/base.py", line 443, in store_result
    request=request, **kwargs)
  File "/home/bx/project/celery/celery/backends/cassandra.py", line 207, in _store_result
    buf_t(self.encode(self.current_task_children(request)))
  File "cassandra/cluster.py", line 2345, in cassandra.cluster.Session.execute
  File "cassandra/cluster.py", line 4304, in cassandra.cluster.ResponseFuture.result
cassandra.OperationTimedOut: errors=errors={'Connection defunct by heartbeat': 'Client request timeout. See Session.execute[_async](timeout)'}, last_host=127.0.0.1:9042, last_host=None
</code></pre></div>
<p dir="auto"></p>
<h1 dir="auto">Fix it</h1>
<p dir="auto">remove  method(CassandraBackend.process_cleanup), it works fine.</p>
<p dir="auto">because.</p>
<p dir="auto">all tasks should share one instance of cassandra.cluster.Cluster and session,   not create one ervery time. that is the correct way to use cassandra-driver</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"> 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" 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"> 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>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="778808199" data-permission-text="Title is private" data-url="https://github.com/DefectDojo/django-DefectDojo/issues/3582" data-hovercard-type="pull_request" data-hovercard-url="/DefectDojo/django-DefectDojo/pull/3582/hovercard" href="https://github.com/DefectDojo/django-DefectDojo/pull/3582">DefectDojo/django-DefectDojo#3582</a></p>
<h4 dir="auto">Possible Duplicates</h4>
<h2 dir="auto">Environment &amp; Settings</h2>
<h1 dir="auto">Steps to Reproduce</h1>
<p dir="auto">I have come across this when running using OpenShift restricted SCC</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="oc logs defect-dojo-defectdojo-celery-worker-78dbb86b48-2rxn2
uid=1000640000(1000640000) gid=0(root) groups=0(root),1000640000
Waiting for database to be reachable [06/Jan/2021 13:40:58] INFO [dojo.models:3474] enabling audit logging
[06/Jan/2021 13:41:00] INFO [dojo.models:3474] enabling audit logging
Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=1000640000 euid=1000640000 gid=0 egid=0"><pre class="notranslate"><code class="notranslate">oc logs defect-dojo-defectdojo-celery-worker-78dbb86b48-2rxn2
uid=1000640000(1000640000) gid=0(root) groups=0(root),1000640000
Waiting for database to be reachable [06/Jan/2021 13:40:58] INFO [dojo.models:3474] enabling audit logging
[06/Jan/2021 13:41:00] INFO [dojo.models:3474] enabling audit logging
Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=1000640000 euid=1000640000 gid=0 egid=0
</code></pre></div>
<h2 dir="auto">Required Dependencies</h2>

<ul dir="auto">
<li><strong>Minimal Python Version</strong>: N/A</li>
<li><strong>Minimal Celery Version</strong>: 4.1.1</li>
<li><strong>Minimal Kombu Version</strong>: 4.1</li>
<li><strong>Minimal Broker Version</strong>: N/A</li>
<li><strong>Minimal Result Backend Version</strong>: N/A</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: N/A</li>
<li><strong>Minimal Broker Client Version</strong>: N/A</li>
<li><strong>Minimal Result Backend Client Version</strong>: N/A</li>
</ul>
<h3 dir="auto">Python Packages</h3>
<h3 dir="auto">Other Dependencies</h3>
<h2 dir="auto">Minimally Reproducible Test Case</h2>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">I believe that GID=0 doesn't give superuser privileges, so am not sure why the celery checks are implemented in this manner.</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">The gid (and egid) being 0 does not give superuser prvilieges<br>
as stated - <a href="https://unix.stackexchange.com/questions/44077/what-does-it-mean-to-be-in-group-0" rel="nofollow">https://unix.stackexchange.com/questions/44077/what-does-it-mean-to-be-in-group-0</a> and <a href="https://docs.celeryproject.org/en/stable/userguide/daemonizing.html#running-the-worker-with-superuser-privileges-root" rel="nofollow">https://docs.celeryproject.org/en/stable/userguide/daemonizing.html#running-the-worker-with-superuser-privileges-root</a></p>