GitHub PullRequestEvent at 2014-07-09 19:43:14
Repository: spree
Actor: jordan-brough
Payload: {"action":"closed","number":43,"pull_request":{"url":"https://api.github.com/repos/bonobos/spree/pulls/43","id":18126207,"html_url":"https://github.com/bonobos/spree/pull/43","diff_url":"https://github.com/bonobos/spree/pull/43.diff","patch_url":"https://github.com/bonobos/spree/pull/43.patch","issue_url":"https://api.github.com/repos/bonobos/spree/issues/43","number":43,"state":"closed","title":"Order locking in controllers","user":{"login":"jordan-brough","id":23050,"avatar_url":"https://avatars.githubusercontent.com/u/23050?","gravatar_id":"3f44348afa54f14119aa08350b0fe178","url":"https://api.github.com/users/jordan-brough","html_url":"https://github.com/jordan-brough","followers_url":"https://api.github.com/users/jordan-brough/followers","following_url":"https://api.github.com/users/jordan-brough/following{/other_user}","gists_url":"https://api.github.com/users/jordan-brough/gists{/gist_id}","starred_url":"https://api.github.com/users/jordan-brough/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordan-brough/subscriptions","organizations_url":"https://api.github.com/users/jordan-brough/orgs","repos_url":"https://api.github.com/users/jordan-brough/repos","events_url":"https://api.github.com/users/jordan-brough/events{/privacy}","received_events_url":"https://api.github.com/users/jordan-brough/received_events","type":"User","site_admin":false},"body":"The existing code for locking orders during requests wasn't doing anything.\r\nA call to `lock` has to be made inside of a transaction to take effect, and there were no open transactions when we were calling it.\r\nSo, the existing code would unlock the order as soon as the line of code with \".lock\" finished executing.  i.e., it was essentially a no-op.\r\n\r\nThis commit introduces the an OrderMutex table that uses the database to provide a mutex for operating on an order. We use this functionality at the controller level.\r\n\r\nIdeally we'd have a clean entry point at the model level where we could use employ this mutex (or even a DB transaction), but at the moment we don't seem to have something like that.\r\n\r\nAlternatively, we could wrap *everything* in the associated controller actions in one giant transaction, and create a lock on the associated order. However, this can affect DB performance and also means that any unhandled exceptions in these endpoints will roll back *all* database changes.  For example, you might charge a credit card, send out an \"order complete\" email, or send a message to your inventory management service, and then blow up on some subsequent (possibly trival) callback and everything in the DB would be rolled back, yet the credit card charge/emails/api calls would still have been sent.\r\n\r\nNOTE: This does not add locking on admin endpoints.  If we get this commit merged in and it works we should add it in admin also.","created_at":"2014-07-08T20:25:04Z","updated_at":"2014-07-09T19:43:14Z","closed_at":"2014-07-09T19:43:14Z","merged_at":null,"merge_commit_sha":"ba6a54e008d8682c73bfa8ed7a42c54b0b37114b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bonobos/spree/pulls/43/commits","review_comments_url":"https://api.github.com/repos/bonobos/spree/pulls/43/comments","review_comment_url":"https://api.github.com/repos/bonobos/spree/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bonobos/spree/issues/43/comments","statuses_url":"https://api.github.com/repos/bonobos/spree/statuses/dc001f548290763d6418e2fa88cbf2a370c5cbf7","head":{"label":"bonobos:fix-order-locking-2-2-dev","ref":"fix-order-locking-2-2-dev","sha":"dc001f548290763d6418e2fa88cbf2a370c5cbf7","user":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?","gravatar_id":"602feb28ab0537735b606888ec993489","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"repo":{"id":12625383,"name":"spree","full_name":"bonobos/spree","owner":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?","gravatar_id":"602feb28ab0537735b606888ec993489","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonobos/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/bonobos/spree","forks_url":"https://api.github.com/repos/bonobos/spree/forks","keys_url":"https://api.github.com/repos/bonobos/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonobos/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonobos/spree/teams","hooks_url":"https://api.github.com/repos/bonobos/spree/hooks","issue_events_url":"https://api.github.com/repos/bonobos/spree/issues/events{/number}","events_url":"https://api.github.com/repos/bonobos/spree/events","assignees_url":"https://api.github.com/repos/bonobos/spree/assignees{/user}","branches_url":"https://api.github.com/repos/bonobos/spree/branches{/branch}","tags_url":"https://api.github.com/repos/bonobos/spree/tags","blobs_url":"https://api.github.com/repos/bonobos/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonobos/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonobos/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonobos/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonobos/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/bonobos/spree/languages","stargazers_url":"https://api.github.com/repos/bonobos/spree/stargazers","contributors_url":"https://api.github.com/repos/bonobos/spree/contributors","subscribers_url":"https://api.github.com/repos/bonobos/spree/subscribers","subscription_url":"https://api.github.com/repos/bonobos/spree/subscription","commits_url":"https://api.github.com/repos/bonobos/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonobos/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonobos/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonobos/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/bonobos/spree/contents/{+path}","compare_url":"https://api.github.com/repos/bonobos/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonobos/spree/merges","archive_url":"https://api.github.com/repos/bonobos/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonobos/spree/downloads","issues_url":"https://api.github.com/repos/bonobos/spree/issues{/number}","pulls_url":"https://api.github.com/repos/bonobos/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/bonobos/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/bonobos/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonobos/spree/labels{/name}","releases_url":"https://api.github.com/repos/bonobos/spree/releases{/id}","created_at":"2013-09-05T18:28:25Z","updated_at":"2014-07-08T16:21:11Z","pushed_at":"2014-07-09T19:35:15Z","git_url":"git://github.com/bonobos/spree.git","ssh_url":"git@github.com:bonobos/spree.git","clone_url":"https://github.com/bonobos/spree.git","svn_url":"https://github.com/bonobos/spree","homepage":"http://spreecommerce.com","size":42326,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"2-2-dev"}},"base":{"label":"bonobos:2-2-dev","ref":"2-2-dev","sha":"9b4d1245608968b1e4b37ac0a15481b39acacc16","user":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?","gravatar_id":"602feb28ab0537735b606888ec993489","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"repo":{"id":12625383,"name":"spree","full_name":"bonobos/spree","owner":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?","gravatar_id":"602feb28ab0537735b606888ec993489","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonobos/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/bonobos/spree","forks_url":"https://api.github.com/repos/bonobos/spree/forks","keys_url":"https://api.github.com/repos/bonobos/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonobos/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonobos/spree/teams","hooks_url":"https://api.github.com/repos/bonobos/spree/hooks","issue_events_url":"https://api.github.com/repos/bonobos/spree/issues/events{/number}","events_url":"https://api.github.com/repos/bonobos/spree/events","assignees_url":"https://api.github.com/repos/bonobos/spree/assignees{/user}","branches_url":"https://api.github.com/repos/bonobos/spree/branches{/branch}","tags_url":"https://api.github.com/repos/bonobos/spree/tags","blobs_url":"https://api.github.com/repos/bonobos/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonobos/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonobos/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonobos/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonobos/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/bonobos/spree/languages","stargazers_url":"https://api.github.com/repos/bonobos/spree/stargazers","contributors_url":"https://api.github.com/repos/bonobos/spree/contributors","subscribers_url":"https://api.github.com/repos/bonobos/spree/subscribers","subscription_url":"https://api.github.com/repos/bonobos/spree/subscription","commits_url":"https://api.github.com/repos/bonobos/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonobos/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonobos/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonobos/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/bonobos/spree/contents/{+path}","compare_url":"https://api.github.com/repos/bonobos/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonobos/spree/merges","archive_url":"https://api.github.com/repos/bonobos/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonobos/spree/downloads","issues_url":"https://api.github.com/repos/bonobos/spree/issues{/number}","pulls_url":"https://api.github.com/repos/bonobos/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/bonobos/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/bonobos/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonobos/spree/labels{/name}","releases_url":"https://api.github.com/repos/bonobos/spree/releases{/id}","created_at":"2013-09-05T18:28:25Z","updated_at":"2014-07-08T16:21:11Z","pushed_at":"2014-07-09T19:35:15Z","git_url":"git://github.com/bonobos/spree.git","ssh_url":"git@github.com:bonobos/spree.git","clone_url":"https://github.com/bonobos/spree.git","svn_url":"https://github.com/bonobos/spree","homepage":"http://spreecommerce.com","size":42326,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"2-2-dev"}},"_links":{"self":{"href":"https://api.github.com/repos/bonobos/spree/pulls/43"},"html":{"href":"https://github.com/bonobos/spree/pull/43"},"issue":{"href":"https://api.github.com/repos/bonobos/spree/issues/43"},"comments":{"href":"https://api.github.com/repos/bonobos/spree/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/bonobos/spree/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/bonobos/spree/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bonobos/spree/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/bonobos/spree/statuses/dc001f548290763d6418e2fa88cbf2a370c5cbf7"}},"merged":false,"mergeable":true,"mergeable_state":"unstable","merged_by":null,"comments":4,"review_comments":0,"commits":2,"additions":219,"deletions":48,"changed_files":18}}