nadeemlab / SPT

Spatial profiling toolbox for spatial characterization of tumor immune microenvironment in multiplex images (https://oncopathtk.org)
https://oncopathtk.org
Other
21 stars 2 forks source link

Remove unnecessary identifiers, causing concurrency conflicts #328

Closed jimmymathews closed 2 months ago

jimmymathews commented 2 months ago

After formally introducing concurrent workers at the FastAPI level, primary key conflicts were observed in the computation task queue table.

    |     self._insert_jobs(cursor, feature_specification)
    |   File "/usr/local/lib/python3.11/site-packages/spatialprofilingtoolbox/ondemand/scheduler.py", line 82, in _insert_jobs
    |     cursor.execute(query)
    |   File "/usr/local/lib/python3.11/site-packages/psycopg/cursor.py", line 732, in execute
    |     raise ex.with_traceback(None)
    | psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "quantitative_feature_value_queue_pkey"

Fix this by removing the unused identifier column (and primary key constraint), introducing a whole row constraint, and converting INSERT to INSERT ON CONFLICT DO NOTHING.