You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
Lately I often get errors like the one mentioned above. It seems like a race condition. When there is a very busy facebook app with many hundred requests per minute the fandjango's "User" model has more than one dataset of the same user. And following requests fail.
'''
MultipleObjectsReturned at /
get() returned more than one User -- it returned 2! Lookup parameters were {'facebook_id': u'100000902133058'}
On line 70 there is checked if the user already exists in the database. If not, on line 80 he will be created. But on line 78 there is a facebook API call which is comparatively slow. During this api call there can be other requests to the webapp which won't find a current user in the database on line 70 and so in the end there will be more than one dataset of one equal user in the database.
I think this should be enforced on database level, so "User.facebook_id" should be unique=True. Then in middleware.py on line 80 it should be catched the IntegrityError and when it's raised it should be checked if facebook_id is set. If not its probably an api exception. If yes, the "User" model should be queried again for the respective facebook_id.
So in my opinion it would be better to replace line 69 to 110 with something like that: http://dpaste.com/662645/ (untested). But it probably can be done a lot better than that.
Hi!
Lately I often get errors like the one mentioned above. It seems like a race condition. When there is a very busy facebook app with many hundred requests per minute the fandjango's "User" model has more than one dataset of the same user. And following requests fail.
'''
MultipleObjectsReturned at /
get() returned more than one User -- it returned 2! Lookup parameters were {'facebook_id': u'100000902133058'}
Request Method: POST
Django Version: 1.3.1
Exception Type: MultipleObjectsReturned
Exception Value:
get() returned more than one User -- it returned 2! Lookup parameters were {'facebook_id': u'100000902133058'}
'''
Anybody else noticed that?
The text was updated successfully, but these errors were encountered: