{"action":"created","comment":{"url":"https://api.github.com/repos/owncloud/core/pulls/comments/110367764","pull_request_review_id":31536771,"id":110367764,"diff_hunk":"@@ -186,18 +186,24 @@ public function getNext() {\n \t\t$update->update('jobs')\n \t\t\t->set('reserved_at', $update->createNamedParameter($this->timeFactory->getTime()))\n \t\t\t->set('last_checked', $update->createNamedParameter($this->timeFactory->getTime()))\n-\t\t\t->where($update->expr()->eq('id', $update->createParameter('jobid')));\n+\t\t\t->where($update->expr()->eq('id', $update->createParameter('jobid')))\n+\t\t\t->andWhere($update->expr()->eq('reserved_at', $update->createParameter('reserved_at')))\n+\t\t\t->andWhere($update->expr()->eq('last_checked', $update->createParameter('last_checked')));\n \n-\t\t$this->connection->lockTable('jobs');\n \t\t$result = $query->execute();\n \t\t$row = $result->fetch();\n \t\t$result->closeCursor();\n \n \t\tif ($row) {\n \t\t\t$update->setParameter('jobid', $row['id']);\n-\t\t\t$update->execute();\n-\t\t\t$this->connection->unlockTable();\n+\t\t\t$update->setParameter('reserved_at', $row['reserved_at']);\n+\t\t\t$update->setParameter('last_checked', $row['last_checked']);\n+\t\t\t$count = $update->execute();\n \n+\t\t\tif ($count === 0) {\n+\t\t\t\t// Background job already executed elsewhere, try again.\n+\t\t\t\treturn $this->getNext();","path":"lib/private/BackgroundJob/JobList.php","position":24,"original_position":24,"commit_id":"54b8a33988b5aabed584117204375265e2bab8e2","original_commit_id":"54b8a33988b5aabed584117204375265e2bab8e2","user":{"login":"PVince81","id":277525,"avatar_url":"https://avatars1.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"body":"Recursion sounds a bit dangerous in the event where a lot of consecutive jobs are discovered that were already executed elsewhere. How realistic is this scenario ?","created_at":"2017-04-07T11:16:43Z","updated_at":"2017-04-07T11:16:43Z","html_url":"https://github.com/owncloud/core/pull/27597#discussion_r110367764","pull_request_url":"https://api.github.com/repos/owncloud/core/pulls/27597","_links":{"self":{"href":"https://api.github.com/repos/owncloud/core/pulls/comments/110367764"},"html":{"href":"https://github.com/owncloud/core/pull/27597#discussion_r110367764"},"pull_request":{"href":"https://api.github.com/repos/owncloud/core/pulls/27597"}}},"pull_request":{"url":"https://api.github.com/repos/owncloud/core/pulls/27597","id":114793615,"html_url":"https://github.com/owncloud/core/pull/27597","diff_url":"https://github.com/owncloud/core/pull/27597.diff","patch_url":"https://github.com/owncloud/core/pull/27597.patch","issue_url":"https://api.github.com/repos/owncloud/core/issues/27597","number":27597,"state":"open","locked":false,"title":"make JobList::next() lock free","user":{"login":"butonic","id":956847,"avatar_url":"https://avatars3.githubusercontent.com/u/956847?v=3","gravatar_id":"","url":"https://api.github.com/users/butonic","html_url":"https://github.com/butonic","followers_url":"https://api.github.com/users/butonic/followers","following_url":"https://api.github.com/users/butonic/following{/other_user}","gists_url":"https://api.github.com/users/butonic/gists{/gist_id}","starred_url":"https://api.github.com/users/butonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/butonic/subscriptions","organizations_url":"https://api.github.com/users/butonic/orgs","repos_url":"https://api.github.com/users/butonic/repos","events_url":"https://api.github.com/users/butonic/events{/privacy}","received_events_url":"https://api.github.com/users/butonic/received_events","type":"User","site_admin":false},"body":"<!--\r\nThanks for submitting a change to ownCloud!\r\n\r\nThis is the bug tracker for the Server component. Find other components at https://github.com/owncloud/core/blob/master/.github/CONTRIBUTING.md#guidelines\r\n\r\nFor fixing potential security issues please see https://owncloud.org/security/\r\n\r\nTo make it possible for us to get your change reviewed and merged please fill out below information carefully.\r\n\r\nPlease note that any kind of change first has to be submitted to the master branch which holds the next major version of ownCloud.\r\n\r\nWe will carefully discuss if your change can or has to be backported to stable branches.\r\n-->\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nadds the reserved_at and last_checked columns to the wuere clause of the update. This allows us to check if the row was updated by this execution and call next() in case another thread already updated this job. \r\n\r\n## Related Issue\r\n<!--- This project only accepts pull requests related to open issues -->\r\n<!--- If suggesting a new feature or change, please discuss it in an issue first -->\r\n<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->\r\n<!--- Please link to the issue here: -->\r\nfixes https://github.com/owncloud/core/issues/27071\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nlocking issues when running cron from multiple machines on galera cluster\r\n\r\n## How Has This Been Tested?\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\ncli, but needs jenkins and verification by @cdamken first, maybe also @Helios07 can test this works as intended in larger installations. \r\n\r\n\r\n## Types of changes\r\n<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->\r\n- [x] Bug fix (non-breaking change which fixes an issue)\r\n- [ ] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Checklist:\r\n<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->\r\n<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n- [x] My code follows the code style of this project.\r\n- [ ] My change requires a change to the documentation.\r\n- [ ] I have updated the documentation accordingly.\r\n- [x] I have read the **CONTRIBUTING** document.\r\n- [ ] I have added tests to cover my changes.\r\n- [ ] All new and existing tests passed.\r\n\r\n","created_at":"2017-04-07T11:07:27Z","updated_at":"2017-04-07T11:16:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"60d5e8e5bc94bbe44d79f38182c90d8496b57f97","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/105","html_url":"https://github.com/owncloud/core/milestone/105","labels_url":"https://api.github.com/repos/owncloud/core/milestones/105/labels","id":2211525,"number":105,"title":"9.1.5","description":null,"creator":{"login":"PVince81","id":277525,"avatar_url":"https://avatars1.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"open_issues":37,"closed_issues":42,"state":"open","created_at":"2016-12-22T07:31:26Z","updated_at":"2017-04-07T11:07:28Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/owncloud/core/pulls/27597/commits","review_comments_url":"https://api.github.com/repos/owncloud/core/pulls/27597/comments","review_comment_url":"https://api.github.com/repos/owncloud/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/owncloud/core/issues/27597/comments","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/54b8a33988b5aabed584117204375265e2bab8e2","head":{"label":"owncloud:stable9.1-lockfree-jobs","ref":"stable9.1-lockfree-jobs","sha":"54b8a33988b5aabed584117204375265e2bab8e2","user":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars0.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"repo":{"id":5550552,"name":"core","full_name":"owncloud/core","owner":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars0.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owncloud/core","description":":cloud: ownCloud web server core (Files, DAV, etc.)","fork":false,"url":"https://api.github.com/repos/owncloud/core","forks_url":"https://api.github.com/repos/owncloud/core/forks","keys_url":"https://api.github.com/repos/owncloud/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owncloud/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owncloud/core/teams","hooks_url":"https://api.github.com/repos/owncloud/core/hooks","issue_events_url":"https://api.github.com/repos/owncloud/core/issues/events{/number}","events_url":"https://api.github.com/repos/owncloud/core/events","assignees_url":"https://api.github.com/repos/owncloud/core/assignees{/user}","branches_url":"https://api.github.com/repos/owncloud/core/branches{/branch}","tags_url":"https://api.github.com/repos/owncloud/core/tags","blobs_url":"https://api.github.com/repos/owncloud/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owncloud/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owncloud/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/owncloud/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/{sha}","languages_url":"https://api.github.com/repos/owncloud/core/languages","stargazers_url":"https://api.github.com/repos/owncloud/core/stargazers","contributors_url":"https://api.github.com/repos/owncloud/core/contributors","subscribers_url":"https://api.github.com/repos/owncloud/core/subscribers","subscription_url":"https://api.github.com/repos/owncloud/core/subscription","commits_url":"https://api.github.com/repos/owncloud/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/owncloud/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/owncloud/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/owncloud/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/owncloud/core/contents/{+path}","compare_url":"https://api.github.com/repos/owncloud/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owncloud/core/merges","archive_url":"https://api.github.com/repos/owncloud/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owncloud/core/downloads","issues_url":"https://api.github.com/repos/owncloud/core/issues{/number}","pulls_url":"https://api.github.com/repos/owncloud/core/pulls{/number}","milestones_url":"https://api.github.com/repos/owncloud/core/milestones{/number}","notifications_url":"https://api.github.com/repos/owncloud/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owncloud/core/labels{/name}","releases_url":"https://api.github.com/repos/owncloud/core/releases{/id}","deployments_url":"https://api.github.com/repos/owncloud/core/deployments","created_at":"2012-08-25T10:32:48Z","updated_at":"2017-04-07T09:53:41Z","pushed_at":"2017-04-07T11:07:28Z","git_url":"git://github.com/owncloud/core.git","ssh_url":"git@github.com:owncloud/core.git","clone_url":"https://github.com/owncloud/core.git","svn_url":"https://github.com/owncloud/core","homepage":"https://owncloud.org/","size":221674,"stargazers_count":5196,"watchers_count":5196,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1675,"mirror_url":null,"open_issues_count":1602,"forks":1675,"open_issues":1602,"watchers":5196,"default_branch":"master"}},"base":{"label":"owncloud:stable9.1","ref":"stable9.1","sha":"e2a1b8e32874f3e5786a3a3beede327b52a76285","user":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars0.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"repo":{"id":5550552,"name":"core","full_name":"owncloud/core","owner":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars0.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owncloud/core","description":":cloud: ownCloud web server core (Files, DAV, etc.)","fork":false,"url":"https://api.github.com/repos/owncloud/core","forks_url":"https://api.github.com/repos/owncloud/core/forks","keys_url":"https://api.github.com/repos/owncloud/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owncloud/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owncloud/core/teams","hooks_url":"https://api.github.com/repos/owncloud/core/hooks","issue_events_url":"https://api.github.com/repos/owncloud/core/issues/events{/number}","events_url":"https://api.github.com/repos/owncloud/core/events","assignees_url":"https://api.github.com/repos/owncloud/core/assignees{/user}","branches_url":"https://api.github.com/repos/owncloud/core/branches{/branch}","tags_url":"https://api.github.com/repos/owncloud/core/tags","blobs_url":"https://api.github.com/repos/owncloud/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owncloud/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owncloud/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/owncloud/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/{sha}","languages_url":"https://api.github.com/repos/owncloud/core/languages","stargazers_url":"https://api.github.com/repos/owncloud/core/stargazers","contributors_url":"https://api.github.com/repos/owncloud/core/contributors","subscribers_url":"https://api.github.com/repos/owncloud/core/subscribers","subscription_url":"https://api.github.com/repos/owncloud/core/subscription","commits_url":"https://api.github.com/repos/owncloud/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/owncloud/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/owncloud/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/owncloud/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/owncloud/core/contents/{+path}","compare_url":"https://api.github.com/repos/owncloud/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owncloud/core/merges","archive_url":"https://api.github.com/repos/owncloud/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owncloud/core/downloads","issues_url":"https://api.github.com/repos/owncloud/core/issues{/number}","pulls_url":"https://api.github.com/repos/owncloud/core/pulls{/number}","milestones_url":"https://api.github.com/repos/owncloud/core/milestones{/number}","notifications_url":"https://api.github.com/repos/owncloud/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owncloud/core/labels{/name}","releases_url":"https://api.github.com/repos/owncloud/core/releases{/id}","deployments_url":"https://api.github.com/repos/owncloud/core/deployments","created_at":"2012-08-25T10:32:48Z","updated_at":"2017-04-07T09:53:41Z","pushed_at":"2017-04-07T11:07:28Z","git_url":"git://github.com/owncloud/core.git","ssh_url":"git@github.com:owncloud/core.git","clone_url":"https://github.com/owncloud/core.git","svn_url":"https://github.com/owncloud/core","homepage":"https://owncloud.org/","size":221674,"stargazers_count":5196,"watchers_count":5196,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1675,"mirror_url":null,"open_issues_count":1602,"forks":1675,"open_issues":1602,"watchers":5196,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/owncloud/core/pulls/27597"},"html":{"href":"https://github.com/owncloud/core/pull/27597"},"issue":{"href":"https://api.github.com/repos/owncloud/core/issues/27597"},"comments":{"href":"https://api.github.com/repos/owncloud/core/issues/27597/comments"},"review_comments":{"href":"https://api.github.com/repos/owncloud/core/pulls/27597/comments"},"review_comment":{"href":"https://api.github.com/repos/owncloud/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/owncloud/core/pulls/27597/commits"},"statuses":{"href":"https://api.github.com/repos/owncloud/core/statuses/54b8a33988b5aabed584117204375265e2bab8e2"}}}}
{"actor":{"display_login":"PVince81"}}