Page MenuHomePhabricator

Catch race conditions when multiple processes try to create the profile for a user
ClosedPublic

Authored by Info-Screen on Apr 22 2019, 6:13 PM.

Details

Summary

When multiple processes try to get() the profile of a user that doesn't already have one in the database
a reace condition might occure. Because a OneToOne Field is used an IntegrityError will be raised.
In case this error is raised, we can be sure someone else created the profile and fetch it again.

Test Plan

None. Testing race conditions is hard.

Diff Detail

Repository
rAPI Server API
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

About the testing part, the current CI script I have for the lib consistently raises it, that could be used for testing. Once this is landed I'll update the API version and see if it still throws the exception

This revision is now accepted and ready to land.Apr 23 2019, 2:32 AM
In D245#5937, @CLOVIS wrote:

About the testing part, the current CI script I have for the lib consistently raises it, that could be used for testing. Once this is landed I'll update the API version and see if it still throws the exception

I tried to run your tests locally in the docker image. Wasn't able reproduce though.

This diff is in the staging repository, so you could try it already.
It should be available under the tag: phabricator/diff/860.

Could you have your runner test with that commit?

After updating the API to master, the error doesn't appear anymore. I'm not sure why that is. Logs on GitLab