Handle race condition with creating users more nicely

This commit is contained in:
Henrik Hodne 2013-10-26 08:33:57 -05:00
parent 8ff052792c
commit c64a006f1d

View File

@ -210,6 +210,7 @@ class Travis::Api::App
end
def fetch
retried ||= false
user = ::User.find_by_github_id(data['id'])
info = drop_token ? self.info : self.info(github_oauth_token: token)
@ -225,6 +226,11 @@ class Travis::Api::App
end
user
rescue ActiveRecord::RecordNotUnique
unless retried
retried = true
retry
end
end
end