lister: Failure during listing on a fresh new db (unicity constraint)
Failure during listing debian distribution (staging):
return super().__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/celery/app/trace.py", line 641, in __protected_call__
return self.run(*args, **kwargs)
File "/usr/lib/python3/dist-packages/swh/lister/debian/tasks.py", line 13, in list_debian_distribution
DebianLister(distribution=distribution, **lister_args).run()
File "/usr/lib/python3/dist-packages/swh/lister/debian/lister.py", line 243, in run
_, new_area_packages = self.ingest_data(None)
File "/usr/lib/python3/dist-packages/swh/lister/core/lister_base.py", line 496, in ingest_data
injected = self.inject_repo_data_into_db(models_list)
File "/usr/lib/python3/dist-packages/swh/lister/debian/lister.py", line 177, in inject_repo_data_into_db
.filter(~exists_tmp_pkg(self.db_session, Package))\
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/query.py", line 2925, in all
return list(self)
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/query.py", line 3080, in __iter__
self.session._autoflush()
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 1582, in _autoflush
util.raise_from_cause(e)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 296, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 277, in reraise
raise value
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 1571, in _autoflush
self.flush()
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 2446, in flush
self._flush(objects)
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 2584, in _flush
transaction.rollback(_capture_exception=True)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 67, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 277, in reraise
raise value
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 2544, in _flush
flush_context.execute()
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/unitofwork.py", line 416, in execute
rec.execute(self)
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/unitofwork.py", line 583, in execute
uow,
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
insert,
File "/usr/lib/python3/dist-packages/sqlalchemy/orm/persistence.py", line 1116, in _emit_insert_statements
statement, params
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 980, in execute
return meth(self, multiparams, params)
File "/usr/lib/python3/dist-packages/sqlalchemy/sql/elements.py", line 273, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1099, in _execute_clauseelement
distilled_params,
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1240, in _execute_context
e, statement, parameters, cursor, context
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1458, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 296, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 276, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1236, in _execute_context
cursor, statement, parameters, context
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "package_area_id_name_version_key"
DETAIL: Key (area_id, name, version)=(1, 0ad, 0.0.21-2) already exists.
[SQL: 'INSERT INTO package (area_id, name, version, directory, files, origin_id, task_id, revision_id) VALUES (%(area_id)s, %(name)s, %(version)s, %(directory)s, %(files)s, %(origin_id)s, %(task_id)s, %(revision_id)s) RETURNING package.id'] [parameters: {'area_id': 1, 'name': '0ad', 'version': '0.0.21-2', 'directory': 'pool/main/0/0ad', 'files': '{"0ad_0.0.21-2.dsc": {"name": "0ad_0.0.21-2.dsc", "size": 2363, "md5sum": "5f2af935f4537ede6169db8946d18d81", "sha256": "ee98572de81be0ffbf039951111f ... (303 characters truncated) ... .tar.xz", "size": 71420, "md5sum": "01d28e643619455fef8d40f1d1e7da7d", "sha256": "2f6e5b751872932971c4dbf618c32ddef1021f195d0457f57030b814cb1749c7"}}', 'origin_id': None, 'task_id': None, 'revision_id': None}] (Background on this error at: http://sqlalche.me/e/gkpj)
Nov 08 09:06:32 worker0 python3[20658]: [2019-11-08 09:06:32,853: INFO/ForkPoolWorker-1] Task swh.lister.debian.tasks.DebianListerTask[36bc65e0-d11a-4d4e-89f1-aef02f54d0d1] succeeded in 273.4153532029595s: None
Migrated from T2070 (view on Phabricator)