openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #10273
Re: Using Foreign Keys
-
To:
openstack@xxxxxxxxxxxxxxxxxxx
-
From:
"Bernhard M. Wiedemann" <bwiedemann@xxxxxxx>
-
Date:
Thu, 19 Apr 2012 19:32:15 +0200
-
In-reply-to:
<18287041.HlWWJP8SzO@belana>
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 04/12/2012 02:35 PM, J. Daniel Schmidt wrote:
> Dear Developers,
>
> While testing our SUSE OpenStack packages we hit a nasty bug and
> reported it as: https://bugs.launchpad.net/keystone/+bug/972502
>
> We found out that the underlying cause was a lack of referential
> integrity[1] using sqlite or mysql. When we tried to reproduce this
> issue on postgresql the usage of foreign keys greatly helped to
> find the cause.
>
> In order to prevent further inconsistencies we created a patch that
> added more foreign keys: https://review.openstack.org/6216
>
> One reviewer commented:
>> i don't approve of adding foreign keys, and we should probably
>> remove the existing ones (in UserTenantMembership and in
>> Endpoint)
>
> and on
> https://review.openstack.org/#patch,sidebyside,6216,3,keystone/identity/backends/sql.py
>>
>
we shouldn't be using foreign keys at all, they are a crutch that are not
>> available everywhere
>
> This was a surprising answer to us as the usage of the foreign keys
> revealed the inconsistency in the first place. So removing them
> elsewhere does in no way improve the situation, it even does not
> help for mysql and sqlite, as SQLAlchemy abstracts them away. We
> also found similar bugs elsewhere:
>
> * https://bugs.launchpad.net/keystone/+bug/959294 *
> https://bugs.launchpad.net/keystone/+bug/973243 *
> https://bugs.launchpad.net/keystone/+bug/974199
>
> In our point of view foreign keys should be used in all possible
> places. This would not harm any database that does not support them
> but helps all of us to find data inconsistencies and related bugs,
> which leads to faster development with fewer bugs.
>
>
> What is your take on these things? How would you take care of data
> consistency otherwise?
>
>
> Thank you for your feedback, Berhard M. Wiedemann J. Daniel
> Schmidt
>
> [1]: http://en.wikipedia.org/wiki/Referential_integrity
Just saw another bug, that would have been caught earlier with foreign
keys:
https://bugs.launchpad.net/nova/+bug/754900
So was this issue discussed on the OpenStack Summit?
Ciao
Bernhard M.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk+QTB8ACgkQSTYLOx37oWRf5gCdE9jLHdRY2vGKU6CZy3hVxtVe
sn0Anjg94EkYBeg2RnBSTTGKovnVLveI
=CS+y
-----END PGP SIGNATURE-----
Follow ups
References