Bug 196252

Summary: [ews-app] Set db_constraint to False for Foreign Keys
Product: WebKit Reporter: Aakash Jain <aakash_jain>
Component: Tools / TestsAssignee: Aakash Jain <aakash_jain>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, ap, commit-queue, dean_johnson, jbedard, kocsen_chung, lforschler, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Aakash Jain 2019-03-26 06:26:38 PDT
Steps table have a ForeignKey build_uid. Since the Build and step events from Buildbot can arrive out of order, we might get step data before build data. In that case, we still want to save the step data.

For sqlite Django seems to allow this by default. However, after switching to PostgreSQL, Django is throwing below exception. We should set ForeignKey.db_constraint=False to allow this condition.


    Step(step_uid, build_uid, result, state_string, started_at, complete_at).save()
  File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 808, in save
    force_update=force_update, update_fields=update_fields)
  File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 838, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/Library/Python/2.7/site-packages/django/db/transaction.py", line 223, in __exit__
    connection.commit()
  File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 262, in commit
    self._commit()
  File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 236, in _commit
    return self.connection.commit()
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 236, in _commit
    return self.connection.commit()
IntegrityError: insert or update on table "ews_step" violates foreign key constraint "ews_step_build_uid_3e89afad_fk_ews_build_uid"
DETAIL:  Key (build_uid)=(1_336) is not present in table "ews_build".
Comment 1 Aakash Jain 2019-03-26 06:27:48 PDT
Created attachment 365962 [details]
Patch
Comment 2 WebKit Commit Bot 2019-03-26 10:13:35 PDT
Comment on attachment 365962 [details]
Patch

Clearing flags on attachment: 365962

Committed r243502: <https://trac.webkit.org/changeset/243502>
Comment 3 WebKit Commit Bot 2019-03-26 10:13:37 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 Radar WebKit Bug Importer 2019-03-26 10:15:05 PDT
<rdar://problem/49278115>