Repository navigation
Open
Labels
bugSomething isn't workingcritical-fixShould be addressed before any other issue/PRsdeployed versionLive problems with deployed versions
Description
Note
Migrated from augurlabs/augur#3457
Originally opened by @cdolfi on 2025-12-11
I think this error will get solved the same way as #93
IntegrityError('(psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "issue-insert-unique"\nDETAIL: Key (issue_url)=(https://api.github.com/repos/pulp/pulp-ui/issues/1) already exists.\n')
Stack Trace
Traceback (most recent call last):
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1938, in _exec_single_context
self.dialect.do_executemany(
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 794, in do_executemany
cursor.executemany(statement, parameters)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "issue-insert-unique"
DETAIL: Key (issue_url)=(https://api.github.com/repos/pulp/pulp-ui/issues/1) already exists.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/augur/.venv/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
R = retval = fun(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/augur/.venv/lib/python3.11/site-packages/celery/app/trace.py", line 736, in __protected_call__
return self.run(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/augur/augur/tasks/github/events.py", line 46, in collect_events
collection_strategy.collect(repo_git, key_auth, core_data_last_collected)
File "/augur/augur/tasks/github/events.py", line 128, in collect
self._process_events(events, repo_id)
File "/augur/augur/tasks/github/events.py", line 167, in _process_events
update_issue_closed_cntrbs_by_repo_id(repo_id)
File "/augur/augur/application/db/lib.py", line 555, in update_issue_closed_cntrbs_by_repo_id
connection.execute(update_stmt, update_data)
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
return meth(
^^^^^
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection
return connection._execute_clauseelement(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1639, in _execute_clauseelement
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1848, in _execute_context
return self._exec_single_context(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1988, in _exec_single_context
self._handle_dbapi_exception(
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2343, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1938, in _exec_single_context
self.dialect.do_executemany(
File "/augur/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 794, in do_executemany
cursor.executemany(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "issue-insert-unique"
DETAIL: Key (issue_url)=(https://api.github.com/repos/pulp/pulp-ui/issues/1) already exists.
[SQL:
UPDATE issues
SET cntrb_id = %(cntrb_id)s
WHERE issue_id = %(issue_id)s
AND repo_id = %(repo_id)s
]
[parameters: [{'cntrb_id': UUID('01035995-d400-0000-0000-000000000000'), 'issue_id': 428805, 'repo_id': 27505}, {'cntrb_id': UUID('01035995-d400-0000-0000-000000000000'), 'issue_id': 428816, 'repo_id': 27505}, {'cntrb_id': UUID('0100047d-c300-0000-0000-000000000000'), 'issue_id': 428821, 'repo_id': 27505}, {'cntrb_id': UUID('01035995-d400-0000-0000-000000000000'), 'issue_id': 428823, 'repo_id': 27505}, {'cntrb_id': UUID('0101724c-7f00-0000-0000-000000000000'), 'issue_id': 212279091, 'repo_id': 27505}, {'cntrb_id': UUID('0100046b-cf00-0000-0000-000000000000'), 'issue_id': 212279092, 'repo_id': 27505}, {'cntrb_id': UUID('0100046b-cf00-0000-0000-000000000000'), 'issue_id': 212279102, 'repo_id': 27505}, {'cntrb_id': UUID('01008560-6200-0000-0000-000000000000'), 'issue_id': 212279103, 'repo_id': 27505} ... displaying 10 of 23 total bound parameter sets ... {'cntrb_id': UUID('0100046b-cf00-0000-0000-000000000000'), 'issue_id': 239085787, 'repo_id': 27505}, {'cntrb_id': UUID('010058be-8500-0000-0000-000000000000'), 'issue_id': 239085788, 'repo_id': 27505}]]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingcritical-fixShould be addressed before any other issue/PRsdeployed versionLive problems with deployed versions
Type
Projects
- StatusShow more project fieldsIn Progress
Activity
collectoss-issue-migrator commentedon Apr 30, 2026
Note
Migrated comment from original
Originally posted by
@mn-ramon 2026-03-27Hi @cdolfi @MoralCode — opened PR augurlabs/augur#3801 to fix this.
The
UPDATEinupdate_issue_closed_cntrbs_by_repo_idwas usingengine.connect()instead ofengine.begin(), so the transaction was never committed in SQLAlchemy 2.0. One-line fix — matches the pattern used everywhere else inlib.py(lines 78, 88, 384, 426).collectoss-issue-migrator commentedon Apr 30, 2026
Note
Migrated comment from original
Originally posted by
@MoralCodeon 2026-03-27I responded in the PR
collectoss-issue-migrator commentedon Apr 30, 2026
Note
Migrated comment from original
Originally posted by
@MoralCodeon 2026-03-28after reviewing the PR mentioned above, it is not a fix for this issue, even though the stack trace points directly to the query being run, its not actually that query that is causing the issue because that query never touches the issue_url, so it couldnt possibly cause this unique violation.
however, analysis by Gemini has led me to what may be the true cause of the issue
duplicate urls already exist in the table (somehow) despite the constraint existing. There are about 528 of them, meaning about 215 or so records with duplicate urls. I imagine these must have existed before the constraint was in place and somehow slipped under the radar.
The below query reveals the affected records in more detail
[-]augur.tasks.github.events.collect_events: duplicate key value violates unique constraint "issue-insert-unique"[/-][+]collectoss.tasks.github.events.collect_events: duplicate key value violates unique constraint "issue-insert-unique"[/+]MoralCode commentedon May 29, 2026
can confirm no more duplicates are present in the database. Unable to confirm 100% if this task is still failing because pulp/pulp-ui is affected by the other similar (PR related) issue, and thus collect_events is not yet being scheduled in flower.
The IDs for a random pulp ui PR number i picked (20) do seem to check out though
Logic walk through
pr_src_id 1968684185
node id PR_kwDOMJXKcc51V7yZ
repo src id 815123057
https://api.github.com/repos/pulp/pulp-ui/pulls/20
id 1968684185
node_id "PR_kwDOMJXKcc51V7yZ"
base.repo.id 815123057
MoralCode commentedon Oct 30, 2026
my queries above no longer seem to return any data (a good sign - the conflict i think exists seems to no longer).
Queries (updated to the new schema names)
MoralCode commentedon Nov 19, 2026
I think this PR may need a similar resolution as was proposed in #580 (once #575 lands)
MoralCode commentedon Nov 20, 2026
This will likely be solved in a similar way to #93 (via the above mentioned PRs), but that hasnt landed yet, so this is blocked