Bug 196252 - [ews-app] Set db_constraint to False for Foreign Keys
Summary: [ews-app] Set db_constraint to False for Foreign Keys
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Aakash Jain
Keywords: InRadar
Depends on:
Reported: 2019-03-26 06:26 PDT by Aakash Jain
Modified: 2019-03-26 10:15 PDT (History)
8 users (show)

See Also:

Patch (1.98 KB, patch)
2019-03-26 06:27 PDT, Aakash Jain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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__
  File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 262, in 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]
Comment 2 WebKit Commit Bot 2019-03-26 10:13:35 PDT
Comment on attachment 365962 [details]

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