Skip to content

Fix missing exception catch in create_partition#291

Merged
cigamit merged 1 commit intoctrliq:mainfrom
gxmezrct:feature/upstream_15691
Apr 8, 2026
Merged

Fix missing exception catch in create_partition#291
cigamit merged 1 commit intoctrliq:mainfrom
gxmezrct:feature/upstream_15691

Conversation

@Klaas-
Copy link
Copy Markdown
Contributor

@Klaas- Klaas- commented Apr 8, 2026

SUMMARY

From original PR to AWX:

Fix error creating partition due to uncaught exception

the primary fix is to simply add an exception class
  to those caught in the except block

This also adds live tests for the general scenario
  although this does not hit the new exception type
ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API
ASCENDER VERSION
25.3.5
ADDITIONAL INFORMATION

Most likely fixes ansible/awx#15628 by pulling upstream fix ansible/awx#15691 according to AWX upstream

Fix error creating partition due to uncaught exception

the primary fix is to simply add an exception class
  to those caught in the except block

This also adds live tests for the general scenario
  although this does not hit the new exception type
@Klaas-
Copy link
Copy Markdown
Contributor Author

Klaas- commented Apr 8, 2026

the error it should fix looks like this on ascender 25.3.5:

Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
psycopg.errors.DuplicateObject: type "main_jobevent_20260407_22" 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.12/site-packages/awx/main/tasks/jobs.py", line 501, in run
    self.pre_run_hook(self.instance, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/awx/main/tasks/jobs.py", line 1072, in pre_run_hook
    super(RunJob, self).pre_run_hook(job, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/awx/main/tasks/jobs.py", line 429, in pre_run_hook
    create_partition(instance.event_class._meta.db_table, start=instance.created)
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/awx/main/utils/common.py", line 1154, in create_partition
    cursor.execute(
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.12/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
django.db.utils.ProgrammingError: type "main_jobevent_20260407_22" already exists

For me this happens occasionally when running a job with multiple slices

@cigamit cigamit merged commit 2cf548f into ctrliq:main Apr 8, 2026
@Klaas- Klaas- deleted the feature/upstream_15691 branch April 9, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate database entry on job launch

3 participants