<p dir="auto">When the first task sent by a client on a fresh celery setup is a group task (or possibly any set of tasks processed concurrently by multiple workers), and PostgreSQL is used as the result backend, the workers fail with an <code class="notranslate">IntegrityError</code> due to a duplicate key.</p>
<h2 dir="auto">Steps to reproduce</h2>
<ol dir="auto">
<li>Send a group task to multiple workers as the first task in a new setup</li>
<li>Retrieve the group result</li>
</ol>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">The workers are able to store their result at the PostgreSQL backend, and the group result is correctly retrieved by the client.</p>
<h2 dir="auto">Actual behavior</h2>
<p dir="auto">The <code class="notranslate">_store_result</code> operation fails on the workers with an <code class="notranslate">IntegrityError</code>. The operation is retried three times, but sometimes this is not sufficient and the group task fails with the <code class="notranslate">IntegrityError</code>.</p>
<p dir="auto">Based on the traceback, my suspicion is that as multiple workers are concurrently processing a task and ultimately want to store their result at the backend, they are concurrently setting up sessions with the database:<br>
</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/02c977d64de54ae53ccbc79a9d86196005ab1beb/celery/backends/database/__init__.py#L95-L105">celery/celery/backends/database/__init__.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 95 to 105
      in
      <a data-pjax="true" class="commit-tease-sha" href="/celery/celery/commit/02c977d64de54ae53ccbc79a9d86196005ab1beb">02c977d</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="L95" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="95"></td>
          <td id="LC95" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">def</span> <span class="pl-v">ResultSession</span>(<span class="pl-s1">self</span>, <span class="pl-s1">session_manager</span><span class="pl-c1">=</span><span class="pl-v">SessionManager</span>()): </td>
        </tr>

        <tr class="border-0">
          <td id="L96" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="96"></td>
          <td id="LC96" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">return</span> <span class="pl-s1">session_manager</span>.<span class="pl-en">session_factory</span>( </td>
        </tr>

        <tr class="border-0">
          <td id="L97" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="97"></td>
          <td id="LC97" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">dburi</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">url</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L98" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="98"></td>
          <td id="LC98" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">short_lived_sessions</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">short_lived_sessions</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L99" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="99"></td>
          <td id="LC99" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-c1">**</span><span class="pl-s1">self</span>.<span class="pl-s1">engine_options</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L100" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="100"></td>
          <td id="LC100" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L101" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="101"></td>
          <td id="LC101" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">@<span class="pl-s1">retry</span></span> </td>
        </tr>

        <tr class="border-0">
          <td id="L102" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="102"></td>
          <td id="LC102" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">def</span> <span class="pl-en">_store_result</span>(<span class="pl-s1">self</span>, <span class="pl-s1">task_id</span>, <span class="pl-s1">result</span>, <span class="pl-s1">state</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L103" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="103"></td>
          <td id="LC103" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                   <span class="pl-s1">traceback</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">max_retries</span><span class="pl-c1">=</span><span class="pl-c1">3</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L104" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="104"></td>
          <td id="LC104" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s">"""Store return value and state of an executed task."""</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L105" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="105"></td>
          <td id="LC105" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">session</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-v">ResultSession</span>() </td>
        </tr>
    </tbody></table>
  </div>
</div>
<br>
As it is the first task the workers process, this entails preparing the models and creating the necessary tables with <code class="notranslate">create_all</code> (using SQLAlchemy):<br>
<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/02c977d64de54ae53ccbc79a9d86196005ab1beb/celery/backends/database/session.py#L53-L60">celery/celery/backends/database/session.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 53 to 60
      in
      <a data-pjax="true" class="commit-tease-sha" href="/celery/celery/commit/02c977d64de54ae53ccbc79a9d86196005ab1beb">02c977d</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="L53" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="53"></td>
          <td id="LC53" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">def</span> <span class="pl-en">prepare_models</span>(<span class="pl-s1">self</span>, <span class="pl-s1">engine</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L54" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="54"></td>
          <td id="LC54" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> <span class="pl-c1">not</span> <span class="pl-s1">self</span>.<span class="pl-s1">prepared</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L55" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="55"></td>
          <td id="LC55" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-v">ResultModelBase</span>.<span class="pl-s1">metadata</span>.<span class="pl-en">create_all</span>(<span class="pl-s1">engine</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L56" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="56"></td>
          <td id="LC56" 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-s1">prepared</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L57" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="57"></td>
          <td id="LC57" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L58" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="58"></td>
          <td id="LC58" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">def</span> <span class="pl-en">session_factory</span>(<span class="pl-s1">self</span>, <span class="pl-s1">dburi</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L59" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="59"></td>
          <td id="LC59" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">engine</span>, <span class="pl-s1">session</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">create_session</span>(<span class="pl-s1">dburi</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L60" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="60"></td>
          <td id="LC60" 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">prepare_models</span>(<span class="pl-s1">engine</span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<br>
It seems PostgreSQL doesn't handle multiple sessions creating the same table very well (<a href="https://www.postgresql.org/message-id/4B967780.1040303%40opinioni.net" rel="nofollow">1</a>,<a href="https://stackoverflow.com/questions/48041134/postgres-create-table-asynchronously" rel="nofollow">2</a>,<a href="https://www.postgresql.org/message-id/CA%2BTgmoZAdYVtwBfp1FL2sMZbiHCWT4UPrzRLNnX1Nb30Ku3-gg%40mail.gmail.com" rel="nofollow">3</a>), so a duplicate key in an index for those tables cause an <code class="notranslate">IntegrityError</code>.<p></p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="257997430" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/4267" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/4267/hovercard" href="https://github.com/celery/celery/issues/4267">#4267</a> could be an issue with a similar cause.</p>
<h2 dir="auto">Traceback</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2018-04-10 13:46:40,433: WARNING/ForkPoolWorker-1] Failed operation _store_result.  Retrying 2 more times.
Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_taskmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 53, in _inner
    return fun(*args, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 105, in _store_result
    session = self.ResultSession()
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 99, in ResultSession
    **self.engine_options)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 59, in session_factory
    self.prepare_models(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py&quot;, line 4004, in create_all
    tables=tables)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 757, in visit_metadata
    _is_metadata_operation=True)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 948, in execute
    return meth(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1009, in _execute_ddl
    compiled
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1200, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1413, in _handle_dbapi_exception
    exc_info
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 186, in reraise
    raise value.with_traceback(tb)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_taskmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_taskmeta (\n\tid INTEGER NOT NULL, \n\ttask_id VARCHAR(155), \n\tstatus VARCHAR(50), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\ttraceback TEXT, \n\tPRIMARY KEY (id), \n\tUNIQUE (task_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)
[2018-04-10 13:46:40,575: WARNING/ForkPoolWorker-1] Failed operation _store_result.  Retrying 1 more times.
Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(taskset_id_sequence, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 53, in _inner
    return fun(*args, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 105, in _store_result
    session = self.ResultSession()
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 99, in ResultSession
    **self.engine_options)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 59, in session_factory
    self.prepare_models(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py&quot;, line 4004, in create_all
    tables=tables)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 757, in visit_metadata
    _is_metadata_operation=True)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 782, in visit_table
    self.traverse_single(column.default)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 820, in visit_sequence
    self.connection.execute(CreateSequence(sequence))
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 948, in execute
    return meth(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1009, in _execute_ddl
    compiled
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1200, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1413, in _handle_dbapi_exception
    exc_info
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 186, in reraise
    raise value.with_traceback(tb)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(taskset_id_sequence, 2200) already exists.
 [SQL: 'CREATE SEQUENCE taskset_id_sequence'] (Background on this error at: http://sqlalche.me/e/gkpj)
[2018-04-10 13:46:40,670: WARNING/ForkPoolWorker-1] Failed operation _store_result.  Retrying 0 more times.
Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 53, in _inner
    return fun(*args, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 105, in _store_result
    session = self.ResultSession()
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 99, in ResultSession
    **self.engine_options)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 59, in session_factory
    self.prepare_models(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py&quot;, line 4004, in create_all
    tables=tables)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 757, in visit_metadata
    _is_metadata_operation=True)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 948, in execute
    return meth(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1009, in _execute_ddl
    compiled
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1200, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1413, in _handle_dbapi_exception
    exc_info
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 186, in reraise
    raise value.with_traceback(tb)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_tasksetmeta (\n\tid INTEGER NOT NULL, \n\ttaskset_id VARCHAR(155), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\tPRIMARY KEY (id), \n\tUNIQUE (taskset_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)
[2018-04-10 13:46:40,675: WARNING/ForkPoolWorker-1] /home/ubuntu/venv/lib/python3.6/site-packages/celery/app/trace.py:549: RuntimeWarning: Exception raised outside body: IntegrityError('(psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;\nDETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.\n',):
Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/app/trace.py&quot;, line 434, in trace_task
    uuid, retval, task_request, publish_result,
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py&quot;, line 152, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py&quot;, line 309, in store_result
    request=request, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 53, in _inner
    return fun(*args, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 105, in _store_result
    session = self.ResultSession()
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 99, in ResultSession
    **self.engine_options)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 59, in session_factory
    self.prepare_models(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py&quot;, line 4004, in create_all
    tables=tables)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 757, in visit_metadata
    _is_metadata_operation=True)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 948, in execute
    return meth(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1009, in _execute_ddl
    compiled
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1200, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1413, in _handle_dbapi_exception
    exc_info
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 186, in reraise
    raise value.with_traceback(tb)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_tasksetmeta (\n\tid INTEGER NOT NULL, \n\ttaskset_id VARCHAR(155), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\tPRIMARY KEY (id), \n\tUNIQUE (taskset_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)

  exc, exc_info.traceback)))
[2018-04-10 13:46:40,712: ERROR/ForkPoolWorker-1] Task setup[cfe2557a-f9a1-4406-86d0-1499166cc1a6] raised unexpected: IntegrityError('(psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;\nDETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.\n',)
Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/app/trace.py&quot;, line 434, in trace_task
    uuid, retval, task_request, publish_result,
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py&quot;, line 152, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py&quot;, line 309, in store_result
    request=request, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 53, in _inner
    return fun(*args, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 105, in _store_result
    session = self.ResultSession()
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py&quot;, line 99, in ResultSession
    **self.engine_options)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 59, in session_factory
    self.prepare_models(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py&quot;, line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py&quot;, line 4004, in create_all
    tables=tables)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 757, in visit_metadata
    _is_metadata_operation=True)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 948, in execute
    return meth(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1009, in _execute_ddl
    compiled
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1200, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1413, in _handle_dbapi_exception
    exc_info
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py&quot;, line 186, in reraise
    raise value.with_traceback(tb)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1193, in _execute_context
    context)
  File &quot;/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint &quot;pg_type_typname_nsp_index&quot;
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_tasksetmeta (\n\tid INTEGER NOT NULL, \n\ttaskset_id VARCHAR(155), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\tPRIMARY KEY (id), \n\tUNIQUE (taskset_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)"><pre class="notranslate"><code class="notranslate">[2018-04-10 13:46:40,433: WARNING/ForkPoolWorker-1] Failed operation _store_result.  Retrying 2 more times.
Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_taskmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 53, in _inner
    return fun(*args, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 105, in _store_result
    session = self.ResultSession()
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 99, in ResultSession
    **self.engine_options)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 59, in session_factory
    self.prepare_models(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py", line 4004, in create_all
    tables=tables)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 757, in visit_metadata
    _is_metadata_operation=True)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
    compiled
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_taskmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_taskmeta (\n\tid INTEGER NOT NULL, \n\ttask_id VARCHAR(155), \n\tstatus VARCHAR(50), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\ttraceback TEXT, \n\tPRIMARY KEY (id), \n\tUNIQUE (task_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)
[2018-04-10 13:46:40,575: WARNING/ForkPoolWorker-1] Failed operation _store_result.  Retrying 1 more times.
Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(taskset_id_sequence, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 53, in _inner
    return fun(*args, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 105, in _store_result
    session = self.ResultSession()
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 99, in ResultSession
    **self.engine_options)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 59, in session_factory
    self.prepare_models(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py", line 4004, in create_all
    tables=tables)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 757, in visit_metadata
    _is_metadata_operation=True)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 782, in visit_table
    self.traverse_single(column.default)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 820, in visit_sequence
    self.connection.execute(CreateSequence(sequence))
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
    compiled
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(taskset_id_sequence, 2200) already exists.
 [SQL: 'CREATE SEQUENCE taskset_id_sequence'] (Background on this error at: http://sqlalche.me/e/gkpj)
[2018-04-10 13:46:40,670: WARNING/ForkPoolWorker-1] Failed operation _store_result.  Retrying 0 more times.
Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 53, in _inner
    return fun(*args, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 105, in _store_result
    session = self.ResultSession()
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 99, in ResultSession
    **self.engine_options)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 59, in session_factory
    self.prepare_models(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py", line 4004, in create_all
    tables=tables)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 757, in visit_metadata
    _is_metadata_operation=True)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
    compiled
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_tasksetmeta (\n\tid INTEGER NOT NULL, \n\ttaskset_id VARCHAR(155), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\tPRIMARY KEY (id), \n\tUNIQUE (taskset_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)
[2018-04-10 13:46:40,675: WARNING/ForkPoolWorker-1] /home/ubuntu/venv/lib/python3.6/site-packages/celery/app/trace.py:549: RuntimeWarning: Exception raised outside body: IntegrityError('(psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"\nDETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.\n',):
Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/app/trace.py", line 434, in trace_task
    uuid, retval, task_request, publish_result,
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py", line 152, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py", line 309, in store_result
    request=request, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 53, in _inner
    return fun(*args, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 105, in _store_result
    session = self.ResultSession()
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 99, in ResultSession
    **self.engine_options)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 59, in session_factory
    self.prepare_models(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py", line 4004, in create_all
    tables=tables)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 757, in visit_metadata
    _is_metadata_operation=True)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
    compiled
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_tasksetmeta (\n\tid INTEGER NOT NULL, \n\ttaskset_id VARCHAR(155), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\tPRIMARY KEY (id), \n\tUNIQUE (taskset_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)

  exc, exc_info.traceback)))
[2018-04-10 13:46:40,712: ERROR/ForkPoolWorker-1] Task setup[cfe2557a-f9a1-4406-86d0-1499166cc1a6] raised unexpected: IntegrityError('(psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"\nDETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.\n',)
Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/app/trace.py", line 434, in trace_task
    uuid, retval, task_request, publish_result,
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py", line 152, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/base.py", line 309, in store_result
    request=request, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 53, in _inner
    return fun(*args, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 105, in _store_result
    session = self.ResultSession()
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/__init__.py", line 99, in ResultSession
    **self.engine_options)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 59, in session_factory
    self.prepare_models(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/celery/backends/database/session.py", line 54, in prepare_models
    ResultModelBase.metadata.create_all(engine)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/schema.py", line 4004, in create_all
    tables=tables)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1940, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1549, in _run_visitor
    **kwargs).traverse_single(element)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 757, in visit_metadata
    _is_metadata_operation=True)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 791, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
    compiled
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists.
 [SQL: '\nCREATE TABLE celery_tasksetmeta (\n\tid INTEGER NOT NULL, \n\ttaskset_id VARCHAR(155), \n\tresult BYTEA, \n\tdate_done TIMESTAMP WITHOUT TIME ZONE, \n\tPRIMARY KEY (id), \n\tUNIQUE (taskset_id)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/gkpj)
</code></pre></div>
<h2 dir="auto">Report</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="software -&gt; celery:4.2.0rc2 (windowlicker) kombu:4.1.0 py:3.6.3
            billiard:3.5.0.3 py-amqp:2.2.2
platform -&gt; system:Linux arch:64bit, ELF imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:db+postgresql://****"><pre class="notranslate"><code class="notranslate">software -&gt; celery:4.2.0rc2 (windowlicker) kombu:4.1.0 py:3.6.3
            billiard:3.5.0.3 py-amqp:2.2.2
platform -&gt; system:Linux arch:64bit, ELF imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:amqp results:db+postgresql://****
</code></pre></div>
<p dir="auto">SQLAlchemy version 1.2.6</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"> 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). 5.0.0</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" checked=""> 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>: 5.0.0</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>
<p dir="auto">Try to install celery 5.0.0 now that click released version 8.0 - it will install click 8.0 and be broken since click_repl 0.1.6 does not work with click 8.0</p>
<p dir="auto">When celery app is then started it produces this output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/python /home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery -A tasks worker -l INFO -E -c 4
Traceback (most recent call last):
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery&quot;, line 8, in &lt;module&gt;
    sys.exit(main())
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/__main__.py&quot;, line 14, in main
    from celery.bin.celery import main as _main
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/celery.py&quot;, line 10, in &lt;module&gt;
    from celery.bin.amqp import amqp
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/amqp.py&quot;, line 7, in &lt;module&gt;
    from click_repl import register_repl
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/click_repl/__init__.py&quot;, line 6, in &lt;module&gt;
    import click._bashcomplete
ModuleNotFoundError: No module named 'click._bashcomplete'

Process finished with exit code 1"><pre class="notranslate"><code class="notranslate">/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/python /home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery -A tasks worker -l INFO -E -c 4
Traceback (most recent call last):
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery", line 8, in &lt;module&gt;
    sys.exit(main())
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/__main__.py", line 14, in main
    from celery.bin.celery import main as _main
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/celery.py", line 10, in &lt;module&gt;
    from celery.bin.amqp import amqp
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/amqp.py", line 7, in &lt;module&gt;
    from click_repl import register_repl
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/click_repl/__init__.py", line 6, in &lt;module&gt;
    import click._bashcomplete
ModuleNotFoundError: No module named 'click._bashcomplete'

Process finished with exit code 1
</code></pre></div>
<h2 dir="auto">Required Dependencies</h2>

<ul dir="auto">
<li><strong>Minimal Python Version</strong>: I tried on 3.9, but it has no influence</li>
<li><strong>Minimal Celery Version</strong>: 5.0.0 exact</li>
<li><strong>Minimal Kombu Version</strong>: N/A</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>

<details>
<summary><b><code class="notranslate">pip freeze</code> Output:</b></summary>
amqp==5.0.5
billiard==3.6.3.0
celery==5.0.0
click==8.0.0
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
flower==1.0.1
humanize==0.5.1
kombu==5.0.2
prometheus-client==0.10.1
prompt-toolkit==3.0.17
pytz==2021.1
redis==3.5.3
six==1.15.0
tornado==6.1
vine==5.0.0
wcwidth==0.2.5
<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>
pip uninstall celery click
pip install celery==5
<p dir="auto">this will now pull celery 5 plus click 8.0 (and all the other stuff celery needs, only click 8.0 is to be fixed)</p>
<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">celery requires click version which can actually be used with click_repl</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">exception on starting celery app</p>

<p dir="auto">Starting celery 5.0.0 with click 8.0 produces an exception as below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/python /home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery -A tasks worker -l INFO -E -c 4
Traceback (most recent call last):
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery&quot;, line 8, in &lt;module&gt;
    sys.exit(main())
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/__main__.py&quot;, line 14, in main
    from celery.bin.celery import main as _main
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/celery.py&quot;, line 10, in &lt;module&gt;
    from celery.bin.amqp import amqp
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/amqp.py&quot;, line 7, in &lt;module&gt;
    from click_repl import register_repl
  File &quot;/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/click_repl/__init__.py&quot;, line 6, in &lt;module&gt;
    import click._bashcomplete
ModuleNotFoundError: No module named 'click._bashcomplete'

Process finished with exit code 1"><pre class="notranslate"><code class="notranslate">/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/python /home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery -A tasks worker -l INFO -E -c 4
Traceback (most recent call last):
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/bin/celery", line 8, in &lt;module&gt;
    sys.exit(main())
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/__main__.py", line 14, in main
    from celery.bin.celery import main as _main
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/celery.py", line 10, in &lt;module&gt;
    from celery.bin.amqp import amqp
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/celery/bin/amqp.py", line 7, in &lt;module&gt;
    from click_repl import register_repl
  File "/home/tomasz_kluczkowski/.virtualenvs/celery-experiments/lib/python3.9/site-packages/click_repl/__init__.py", line 6, in &lt;module&gt;
    import click._bashcomplete
ModuleNotFoundError: No module named 'click._bashcomplete'

Process finished with exit code 1
</code></pre></div>
<p dir="auto">This can be easily fixed by changing requirements for 5.0.0 tag for click to be same as on 5.0.5: click &gt;=7, &lt;8</p>