Skip to content

backport-providers-2020.5.20rc2

@ashb ashb tagged this 19 May 12:21
We noticed our Celery tests failing sometimes with

> (psycopg2.errors.UniqueViolation) duplicate key value violates unique
> constraint "pg_type_typname_nsp_index"
> DETAIL:  Key (typname, typnamespace)=(celery_tasksetmeta, 2200) already exists

It appears this is a race condition in SQLAlchemy's "create_all()"
function, where it first checks which tables exist, builds up a list of
`CREATE TABLE` statements, then issues them. Thus if two celery worker
processes start at the same time, they will find the the table doesn't
yet exist, and both try to create it.

This is _probably_ a bug in SQLA, but this should be an easy enough fix
here, to just ensure that the table exists before launching any Celery tasks.
Assets 2
Loading