hasjob icon indicating copy to clipboard operation
hasjob copied to clipboard

EventSession cascade issues

Open jace opened this issue 8 years ago • 0 comments

Hasjob in production is occasionally reporting errors that appear to be caused by a badly configured cascade:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/rq/worker.py", line 568, in perform_job
    rv = job.perform()
  File "/usr/local/lib/python2.7/dist-packages/rq/job.py", line 495, in perform
    self._result = self.func(*self.args, **self.kwargs)
  File "./hasjob/views/helper.py", line 467, in save_jobview
    jvs = failsafe_add(db.session, jvs, event_session_id=event_session_id, jobpost_id=jobpost_id)
  File "/home/hasgeek/dependencies/coaster/coaster/sqlalchemy.py", line 813, in failsafe_add
    raise e
IntegrityError: (psycopg2.IntegrityError) insert or update on table "job_view_session" violates foreign key constraint "job_view_session_event_session_id_fkey"
DETAIL:  Key (event_session_id)=(2226388) is not present in table "event_session".
 [SQL: "INSERT INTO job_view_session (created_at, updated_at, datetime, event_session_id, jobpost_id, bgroup, cointoss, crosstoss) VALUES (TIMEZONE('utc', CURRENT_TIMESTAMP), TIMEZONE('utc', CURRENT_TIMESTAMP), %(datetime)s, %(event_session_id)s, %(jobpost_id)s, %(bgroup)s, %(cointoss)s, %(crosstoss)s)"] [parameters: {'event_session_id': 2226388, 'crosstoss': False, 'datetime': datetime.datetime(2016, 6, 2, 11, 46, 3, 729203), 'bgroup': None, 'cointoss': False, 'jobpost_id': 40618}]

If the EventSession has a primary key, it must have been present in the database at some point. Since there is no code to delete a session, it can only be missing because of a misconfigured cascade.

jace avatar Jul 13 '16 08:07 jace