{"action":"created","comment":{"url":"https://api.github.com/repos/3scale/porta/pulls/comments/220145283","pull_request_review_id":158482442,"id":220145283,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMDE0NTI4Mw==","diff_hunk":"@@ -166,7 +166,7 @@ def create_invoice(opts = {})\n   end\n \n   def create_invoice_counter(period)\n-    invoice_prefix = (billing_monthly? ? period : period.begin.year).to_param\n+    invoice_prefix = period.to_param[0..(billing_monthly? ? 6 : 3)]","path":"app/models/finance/billing_strategy.rb","position":5,"original_position":5,"commit_id":"c7be25228d5b96dd605d69b03309d1cef9e14bdb","original_commit_id":"c7be25228d5b96dd605d69b03309d1cef9e14bdb","user":{"login":"hallelujah","id":64276,"node_id":"MDQ6VXNlcjY0Mjc2","avatar_url":"https://avatars3.githubusercontent.com/u/64276?v=4","gravatar_id":"","url":"https://api.github.com/users/hallelujah","html_url":"https://github.com/hallelujah","followers_url":"https://api.github.com/users/hallelujah/followers","following_url":"https://api.github.com/users/hallelujah/following{/other_user}","gists_url":"https://api.github.com/users/hallelujah/gists{/gist_id}","starred_url":"https://api.github.com/users/hallelujah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hallelujah/subscriptions","organizations_url":"https://api.github.com/users/hallelujah/orgs","repos_url":"https://api.github.com/users/hallelujah/repos","events_url":"https://api.github.com/users/hallelujah/events{/privacy}","received_events_url":"https://api.github.com/users/hallelujah/received_events","type":"User","site_admin":false},"body":"I think it is because you serialize it as a date?","created_at":"2018-09-25T10:53:46Z","updated_at":"2018-09-25T10:53:46Z","html_url":"https://github.com/3scale/porta/pull/30#discussion_r220145283","pull_request_url":"https://api.github.com/repos/3scale/porta/pulls/30","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/3scale/porta/pulls/comments/220145283"},"html":{"href":"https://github.com/3scale/porta/pull/30#discussion_r220145283"},"pull_request":{"href":"https://api.github.com/repos/3scale/porta/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/3scale/porta/pulls/30","id":216932513,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2OTMyNTEz","html_url":"https://github.com/3scale/porta/pull/30","diff_url":"https://github.com/3scale/porta/pull/30.diff","patch_url":"https://github.com/3scale/porta/pull/30.patch","issue_url":"https://api.github.com/repos/3scale/porta/issues/30","number":30,"state":"open","locked":false,"title":"[wip] [billing] Fix create invoice deadlock","user":{"login":"guicassolato","id":1842261,"node_id":"MDQ6VXNlcjE4NDIyNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/1842261?v=4","gravatar_id":"","url":"https://api.github.com/users/guicassolato","html_url":"https://github.com/guicassolato","followers_url":"https://api.github.com/users/guicassolato/followers","following_url":"https://api.github.com/users/guicassolato/following{/other_user}","gists_url":"https://api.github.com/users/guicassolato/gists{/gist_id}","starred_url":"https://api.github.com/users/guicassolato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guicassolato/subscriptions","organizations_url":"https://api.github.com/users/guicassolato/orgs","repos_url":"https://api.github.com/users/guicassolato/repos","events_url":"https://api.github.com/users/guicassolato/events{/privacy}","received_events_url":"https://api.github.com/users/guicassolato/received_events","type":"User","site_admin":false},"body":"<!--  Thanks for sending a pull request!  Here are some tips for you:\r\n1. Please remember to ALWAYS open an issue before starting to work on your pull request. Please take the time to validate your intentions for the pull request with the project maintainers before spending the time to work on it, so your time does not go to waste. \r\n2. If this is your first time, please make sure you've gone through the Contribution guide.\r\n3. If the PR is unfinished, add a `[WIP]` at the start of the PR title. You can remove it when it's ready to be reviewed.\r\n-->\r\n\r\n**What this PR does / why we need it**:\r\n\r\nIt makes the triggers (Mysql and Oracle) on the `invoices` table to use the primary key of the table to perform the update of the friendly id, rather than the composite key (provider_account_id, invoice_prefix).\r\n\r\nThis prevents concurrent transactions to deadlock, specially in Mysql where a bugs seems to make granted shared locks to take precedence of crossed exclusive lock requests between transactions. T1 holds a shared lock, T2 requests exclusive lock on the same record and waits, but then T1 also requests exclusive lock despite of the shared lock granted.\r\n\r\n**Which issue(s) this PR fixes** \r\n\r\nCloses https://github.com/3scale/porta/issues/28\r\n\r\n**Special notes for your reviewer**:","created_at":"2018-09-20T11:10:20Z","updated_at":"2018-09-25T10:53:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cf902c47de111b2a712b881bc65cfecb415a1f6","assignee":{"login":"guicassolato","id":1842261,"node_id":"MDQ6VXNlcjE4NDIyNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/1842261?v=4","gravatar_id":"","url":"https://api.github.com/users/guicassolato","html_url":"https://github.com/guicassolato","followers_url":"https://api.github.com/users/guicassolato/followers","following_url":"https://api.github.com/users/guicassolato/following{/other_user}","gists_url":"https://api.github.com/users/guicassolato/gists{/gist_id}","starred_url":"https://api.github.com/users/guicassolato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guicassolato/subscriptions","organizations_url":"https://api.github.com/users/guicassolato/orgs","repos_url":"https://api.github.com/users/guicassolato/repos","events_url":"https://api.github.com/users/guicassolato/events{/privacy}","received_events_url":"https://api.github.com/users/guicassolato/received_events","type":"User","site_admin":false},"assignees":[{"login":"guicassolato","id":1842261,"node_id":"MDQ6VXNlcjE4NDIyNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/1842261?v=4","gravatar_id":"","url":"https://api.github.com/users/guicassolato","html_url":"https://github.com/guicassolato","followers_url":"https://api.github.com/users/guicassolato/followers","following_url":"https://api.github.com/users/guicassolato/following{/other_user}","gists_url":"https://api.github.com/users/guicassolato/gists{/gist_id}","starred_url":"https://api.github.com/users/guicassolato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guicassolato/subscriptions","organizations_url":"https://api.github.com/users/guicassolato/orgs","repos_url":"https://api.github.com/users/guicassolato/repos","events_url":"https://api.github.com/users/guicassolato/events{/privacy}","received_events_url":"https://api.github.com/users/guicassolato/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1061163922,"node_id":"MDU6TGFiZWwxMDYxMTYzOTIy","url":"https://api.github.com/repos/3scale/porta/labels/jenkins","name":"jenkins","color":"c2e0c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/3scale/porta/pulls/30/commits","review_comments_url":"https://api.github.com/repos/3scale/porta/pulls/30/comments","review_comment_url":"https://api.github.com/repos/3scale/porta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/3scale/porta/issues/30/comments","statuses_url":"https://api.github.com/repos/3scale/porta/statuses/c7be25228d5b96dd605d69b03309d1cef9e14bdb","head":{"label":"3scale:bug/fix-invoice-counter-deadlock","ref":"bug/fix-invoice-counter-deadlock","sha":"c7be25228d5b96dd605d69b03309d1cef9e14bdb","user":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"repo":{"id":149315920,"node_id":"MDEwOlJlcG9zaXRvcnkxNDkzMTU5MjA=","name":"porta","full_name":"3scale/porta","private":false,"owner":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/3scale/porta","description":"Red Hat 3scale API Management User Interface","fork":false,"url":"https://api.github.com/repos/3scale/porta","forks_url":"https://api.github.com/repos/3scale/porta/forks","keys_url":"https://api.github.com/repos/3scale/porta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3scale/porta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3scale/porta/teams","hooks_url":"https://api.github.com/repos/3scale/porta/hooks","issue_events_url":"https://api.github.com/repos/3scale/porta/issues/events{/number}","events_url":"https://api.github.com/repos/3scale/porta/events","assignees_url":"https://api.github.com/repos/3scale/porta/assignees{/user}","branches_url":"https://api.github.com/repos/3scale/porta/branches{/branch}","tags_url":"https://api.github.com/repos/3scale/porta/tags","blobs_url":"https://api.github.com/repos/3scale/porta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3scale/porta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3scale/porta/git/refs{/sha}","trees_url":"https://api.github.com/repos/3scale/porta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3scale/porta/statuses/{sha}","languages_url":"https://api.github.com/repos/3scale/porta/languages","stargazers_url":"https://api.github.com/repos/3scale/porta/stargazers","contributors_url":"https://api.github.com/repos/3scale/porta/contributors","subscribers_url":"https://api.github.com/repos/3scale/porta/subscribers","subscription_url":"https://api.github.com/repos/3scale/porta/subscription","commits_url":"https://api.github.com/repos/3scale/porta/commits{/sha}","git_commits_url":"https://api.github.com/repos/3scale/porta/git/commits{/sha}","comments_url":"https://api.github.com/repos/3scale/porta/comments{/number}","issue_comment_url":"https://api.github.com/repos/3scale/porta/issues/comments{/number}","contents_url":"https://api.github.com/repos/3scale/porta/contents/{+path}","compare_url":"https://api.github.com/repos/3scale/porta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3scale/porta/merges","archive_url":"https://api.github.com/repos/3scale/porta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3scale/porta/downloads","issues_url":"https://api.github.com/repos/3scale/porta/issues{/number}","pulls_url":"https://api.github.com/repos/3scale/porta/pulls{/number}","milestones_url":"https://api.github.com/repos/3scale/porta/milestones{/number}","notifications_url":"https://api.github.com/repos/3scale/porta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3scale/porta/labels{/name}","releases_url":"https://api.github.com/repos/3scale/porta/releases{/id}","deployments_url":"https://api.github.com/repos/3scale/porta/deployments","created_at":"2018-09-18T16:03:13Z","updated_at":"2018-09-25T09:38:40Z","pushed_at":"2018-09-25T10:37:13Z","git_url":"git://github.com/3scale/porta.git","ssh_url":"git@github.com:3scale/porta.git","clone_url":"https://github.com/3scale/porta.git","svn_url":"https://github.com/3scale/porta","homepage":"","size":16730,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":34,"watchers":5,"default_branch":"master"}},"base":{"label":"3scale:master","ref":"master","sha":"617b611d769059b0839f2eb0749784323bf5da31","user":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"repo":{"id":149315920,"node_id":"MDEwOlJlcG9zaXRvcnkxNDkzMTU5MjA=","name":"porta","full_name":"3scale/porta","private":false,"owner":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/3scale/porta","description":"Red Hat 3scale API Management User Interface","fork":false,"url":"https://api.github.com/repos/3scale/porta","forks_url":"https://api.github.com/repos/3scale/porta/forks","keys_url":"https://api.github.com/repos/3scale/porta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3scale/porta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3scale/porta/teams","hooks_url":"https://api.github.com/repos/3scale/porta/hooks","issue_events_url":"https://api.github.com/repos/3scale/porta/issues/events{/number}","events_url":"https://api.github.com/repos/3scale/porta/events","assignees_url":"https://api.github.com/repos/3scale/porta/assignees{/user}","branches_url":"https://api.github.com/repos/3scale/porta/branches{/branch}","tags_url":"https://api.github.com/repos/3scale/porta/tags","blobs_url":"https://api.github.com/repos/3scale/porta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3scale/porta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3scale/porta/git/refs{/sha}","trees_url":"https://api.github.com/repos/3scale/porta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3scale/porta/statuses/{sha}","languages_url":"https://api.github.com/repos/3scale/porta/languages","stargazers_url":"https://api.github.com/repos/3scale/porta/stargazers","contributors_url":"https://api.github.com/repos/3scale/porta/contributors","subscribers_url":"https://api.github.com/repos/3scale/porta/subscribers","subscription_url":"https://api.github.com/repos/3scale/porta/subscription","commits_url":"https://api.github.com/repos/3scale/porta/commits{/sha}","git_commits_url":"https://api.github.com/repos/3scale/porta/git/commits{/sha}","comments_url":"https://api.github.com/repos/3scale/porta/comments{/number}","issue_comment_url":"https://api.github.com/repos/3scale/porta/issues/comments{/number}","contents_url":"https://api.github.com/repos/3scale/porta/contents/{+path}","compare_url":"https://api.github.com/repos/3scale/porta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3scale/porta/merges","archive_url":"https://api.github.com/repos/3scale/porta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3scale/porta/downloads","issues_url":"https://api.github.com/repos/3scale/porta/issues{/number}","pulls_url":"https://api.github.com/repos/3scale/porta/pulls{/number}","milestones_url":"https://api.github.com/repos/3scale/porta/milestones{/number}","notifications_url":"https://api.github.com/repos/3scale/porta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3scale/porta/labels{/name}","releases_url":"https://api.github.com/repos/3scale/porta/releases{/id}","deployments_url":"https://api.github.com/repos/3scale/porta/deployments","created_at":"2018-09-18T16:03:13Z","updated_at":"2018-09-25T09:38:40Z","pushed_at":"2018-09-25T10:37:13Z","git_url":"git://github.com/3scale/porta.git","ssh_url":"git@github.com:3scale/porta.git","clone_url":"https://github.com/3scale/porta.git","svn_url":"https://github.com/3scale/porta","homepage":"","size":16730,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":34,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/3scale/porta/pulls/30"},"html":{"href":"https://github.com/3scale/porta/pull/30"},"issue":{"href":"https://api.github.com/repos/3scale/porta/issues/30"},"comments":{"href":"https://api.github.com/repos/3scale/porta/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/3scale/porta/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/3scale/porta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/3scale/porta/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/3scale/porta/statuses/c7be25228d5b96dd605d69b03309d1cef9e14bdb"}},"author_association":"NONE"}}
{"actor":{"display_login":"hallelujah"}}