Why are the jobs failing with the error "psycopg2.errors.DuplicateTable: relation "main_projectupdateevent_YYYYMMDD_xx" already exists" on Automation Controller?

Solution Verified - Updated -

Issue

  • When I launch a job, the job fails intermittently with the below error.

    Traceback (most recent call last):
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
       return self.cursor.execute(sql)
    psycopg2.errors.DuplicateTable: relation "main_projectupdateevent_2022xxxx_xx" already exists
    
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 449, in run
       self.pre_run_hook(self.instance, private_data_dir)
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 946, in pre_run_hook
       create_partition(local_project_sync.event_class._meta.db_table, start=local_project_sync.created)
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/utils/common.py", line 1145, in create_partition
    cursor.execute(
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
     File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
    django.db.utils.ProgrammingError: relation "main_projectupdateevent_2022xxxx_xx" already exists
    

Environment

  • Ansible automation controller <= 4.0.0, 4.1.2, 4.2.0 (Ansible Automation Platform <= 2.0.0, 2.1.2, 2.2.0)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content