{"action":"closed","number":11646,"pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/11646","id":54891274,"html_url":"https://github.com/laravel/framework/pull/11646","diff_url":"https://github.com/laravel/framework/pull/11646.diff","patch_url":"https://github.com/laravel/framework/pull/11646.patch","issue_url":"https://api.github.com/repos/laravel/framework/issues/11646","number":11646,"state":"closed","locked":false,"title":"[5.2] Delayed the call to fitersPass() to when scheduled task is run","user":{"login":"jedrzej","id":291904,"avatar_url":"https://avatars.githubusercontent.com/u/291904?v=3","gravatar_id":"","url":"https://api.github.com/users/jedrzej","html_url":"https://github.com/jedrzej","followers_url":"https://api.github.com/users/jedrzej/followers","following_url":"https://api.github.com/users/jedrzej/following{/other_user}","gists_url":"https://api.github.com/users/jedrzej/gists{/gist_id}","starred_url":"https://api.github.com/users/jedrzej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedrzej/subscriptions","organizations_url":"https://api.github.com/users/jedrzej/orgs","repos_url":"https://api.github.com/users/jedrzej/repos","events_url":"https://api.github.com/users/jedrzej/events{/privacy}","received_events_url":"https://api.github.com/users/jedrzej/received_events","type":"User","site_admin":false},"body":"I've come upon this issue when trying to executing multiple time-consuming tasks while using **withoutOverlapping()** - as a result 2 instances of given task were executed even though **withoutOverlapping()** was called.\r\n\r\nWhen **artisan schedule:run** is run, first the list of tasks that are due to be run is built. **withoutOverlapping()** checks for existence of a mutex file for given task in **storage/framework/** - if it does not exist, a task is scheduled to be run. All scheduled tasks are executed in a sequence and that mutex file is created the moment the task starts executing. Therefore there is a delay between checking if the mutex file exists and the moment the task gets executed. This may cause time-consuming tasks to be run in parallel even though they should not overlap.\r\n\r\nSample scenario:\r\n- tasks T1 and T2 should run every minute without overlapping\r\n- first instance of schedule:run - S1 - is executed and schedules T1 and T2 to be run\r\n- S1 executes T1, mutex file for T1 is created, T1 takes more than a minute to finish\r\n- in the meanwhile second instance of schedule:run - S2 - is executed a minute later\r\n- S2 sees that there is a mutex file for T1 that is still running, so S2 starts T2\r\n- T1 started by S1 finishes, therefore S1, having previously scheduled T2 to run, starts T2\r\n- **two instances of T2 are running at the same time even thought they are not supposed to overlap**\r\n\r\nIt can happen in other scenarios as well, whenever multiple tasks are scheduled and application state can change between the moment **schedule:run** is triggered and the moment when scheduled task is executed.\r\n\r\nWhen **schedule:run** is executed, schedule is built using expressions, filters, rejects and current environment. While expressions and current environment won't change while scheduled tasks are running, state that is checked by filters and rejects is likely to change. Therefore it makes sense to do those checks when the task is about to run, not when **schedule:run** is triggered.","created_at":"2016-01-01T13:21:56Z","updated_at":"2016-01-01T17:25:13Z","closed_at":"2016-01-01T17:25:13Z","merged_at":"2016-01-01T17:25:13Z","merge_commit_sha":"c5853ec51565f25d7a6f5e725ac2f441393692de","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/laravel/framework/pulls/11646/commits","review_comments_url":"https://api.github.com/repos/laravel/framework/pulls/11646/comments","review_comment_url":"https://api.github.com/repos/laravel/framework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/laravel/framework/issues/11646/comments","statuses_url":"https://api.github.com/repos/laravel/framework/statuses/d8ce94b7e835a314edb325f380910e0b126d192d","head":{"label":"jedrzej:5.2","ref":"5.2","sha":"d8ce94b7e835a314edb325f380910e0b126d192d","user":{"login":"jedrzej","id":291904,"avatar_url":"https://avatars.githubusercontent.com/u/291904?v=3","gravatar_id":"","url":"https://api.github.com/users/jedrzej","html_url":"https://github.com/jedrzej","followers_url":"https://api.github.com/users/jedrzej/followers","following_url":"https://api.github.com/users/jedrzej/following{/other_user}","gists_url":"https://api.github.com/users/jedrzej/gists{/gist_id}","starred_url":"https://api.github.com/users/jedrzej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedrzej/subscriptions","organizations_url":"https://api.github.com/users/jedrzej/orgs","repos_url":"https://api.github.com/users/jedrzej/repos","events_url":"https://api.github.com/users/jedrzej/events{/privacy}","received_events_url":"https://api.github.com/users/jedrzej/received_events","type":"User","site_admin":false},"repo":{"id":48877672,"name":"framework","full_name":"jedrzej/framework","owner":{"login":"jedrzej","id":291904,"avatar_url":"https://avatars.githubusercontent.com/u/291904?v=3","gravatar_id":"","url":"https://api.github.com/users/jedrzej","html_url":"https://github.com/jedrzej","followers_url":"https://api.github.com/users/jedrzej/followers","following_url":"https://api.github.com/users/jedrzej/following{/other_user}","gists_url":"https://api.github.com/users/jedrzej/gists{/gist_id}","starred_url":"https://api.github.com/users/jedrzej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedrzej/subscriptions","organizations_url":"https://api.github.com/users/jedrzej/orgs","repos_url":"https://api.github.com/users/jedrzej/repos","events_url":"https://api.github.com/users/jedrzej/events{/privacy}","received_events_url":"https://api.github.com/users/jedrzej/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jedrzej/framework","description":"","fork":true,"url":"https://api.github.com/repos/jedrzej/framework","forks_url":"https://api.github.com/repos/jedrzej/framework/forks","keys_url":"https://api.github.com/repos/jedrzej/framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jedrzej/framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jedrzej/framework/teams","hooks_url":"https://api.github.com/repos/jedrzej/framework/hooks","issue_events_url":"https://api.github.com/repos/jedrzej/framework/issues/events{/number}","events_url":"https://api.github.com/repos/jedrzej/framework/events","assignees_url":"https://api.github.com/repos/jedrzej/framework/assignees{/user}","branches_url":"https://api.github.com/repos/jedrzej/framework/branches{/branch}","tags_url":"https://api.github.com/repos/jedrzej/framework/tags","blobs_url":"https://api.github.com/repos/jedrzej/framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jedrzej/framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jedrzej/framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/jedrzej/framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jedrzej/framework/statuses/{sha}","languages_url":"https://api.github.com/repos/jedrzej/framework/languages","stargazers_url":"https://api.github.com/repos/jedrzej/framework/stargazers","contributors_url":"https://api.github.com/repos/jedrzej/framework/contributors","subscribers_url":"https://api.github.com/repos/jedrzej/framework/subscribers","subscription_url":"https://api.github.com/repos/jedrzej/framework/subscription","commits_url":"https://api.github.com/repos/jedrzej/framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/jedrzej/framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/jedrzej/framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/jedrzej/framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/jedrzej/framework/contents/{+path}","compare_url":"https://api.github.com/repos/jedrzej/framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jedrzej/framework/merges","archive_url":"https://api.github.com/repos/jedrzej/framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jedrzej/framework/downloads","issues_url":"https://api.github.com/repos/jedrzej/framework/issues{/number}","pulls_url":"https://api.github.com/repos/jedrzej/framework/pulls{/number}","milestones_url":"https://api.github.com/repos/jedrzej/framework/milestones{/number}","notifications_url":"https://api.github.com/repos/jedrzej/framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jedrzej/framework/labels{/name}","releases_url":"https://api.github.com/repos/jedrzej/framework/releases{/id}","created_at":"2016-01-01T12:34:52Z","updated_at":"2016-01-01T12:34:56Z","pushed_at":"2016-01-01T13:40:35Z","git_url":"git://github.com/jedrzej/framework.git","ssh_url":"git@github.com:jedrzej/framework.git","clone_url":"https://github.com/jedrzej/framework.git","svn_url":"https://github.com/jedrzej/framework","homepage":"http://laravel.com","size":20510,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"5.2"}},"base":{"label":"laravel:5.2","ref":"5.2","sha":"34e21024bf6f581739c726940ff8b057179f88a8","user":{"login":"laravel","id":958072,"avatar_url":"https://avatars.githubusercontent.com/u/958072?v=3","gravatar_id":"","url":"https://api.github.com/users/laravel","html_url":"https://github.com/laravel","followers_url":"https://api.github.com/users/laravel/followers","following_url":"https://api.github.com/users/laravel/following{/other_user}","gists_url":"https://api.github.com/users/laravel/gists{/gist_id}","starred_url":"https://api.github.com/users/laravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laravel/subscriptions","organizations_url":"https://api.github.com/users/laravel/orgs","repos_url":"https://api.github.com/users/laravel/repos","events_url":"https://api.github.com/users/laravel/events{/privacy}","received_events_url":"https://api.github.com/users/laravel/received_events","type":"Organization","site_admin":false},"repo":{"id":7548986,"name":"framework","full_name":"laravel/framework","owner":{"login":"laravel","id":958072,"avatar_url":"https://avatars.githubusercontent.com/u/958072?v=3","gravatar_id":"","url":"https://api.github.com/users/laravel","html_url":"https://github.com/laravel","followers_url":"https://api.github.com/users/laravel/followers","following_url":"https://api.github.com/users/laravel/following{/other_user}","gists_url":"https://api.github.com/users/laravel/gists{/gist_id}","starred_url":"https://api.github.com/users/laravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laravel/subscriptions","organizations_url":"https://api.github.com/users/laravel/orgs","repos_url":"https://api.github.com/users/laravel/repos","events_url":"https://api.github.com/users/laravel/events{/privacy}","received_events_url":"https://api.github.com/users/laravel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/laravel/framework","description":"","fork":false,"url":"https://api.github.com/repos/laravel/framework","forks_url":"https://api.github.com/repos/laravel/framework/forks","keys_url":"https://api.github.com/repos/laravel/framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laravel/framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laravel/framework/teams","hooks_url":"https://api.github.com/repos/laravel/framework/hooks","issue_events_url":"https://api.github.com/repos/laravel/framework/issues/events{/number}","events_url":"https://api.github.com/repos/laravel/framework/events","assignees_url":"https://api.github.com/repos/laravel/framework/assignees{/user}","branches_url":"https://api.github.com/repos/laravel/framework/branches{/branch}","tags_url":"https://api.github.com/repos/laravel/framework/tags","blobs_url":"https://api.github.com/repos/laravel/framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laravel/framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laravel/framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/laravel/framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laravel/framework/statuses/{sha}","languages_url":"https://api.github.com/repos/laravel/framework/languages","stargazers_url":"https://api.github.com/repos/laravel/framework/stargazers","contributors_url":"https://api.github.com/repos/laravel/framework/contributors","subscribers_url":"https://api.github.com/repos/laravel/framework/subscribers","subscription_url":"https://api.github.com/repos/laravel/framework/subscription","commits_url":"https://api.github.com/repos/laravel/framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/laravel/framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/laravel/framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/laravel/framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/laravel/framework/contents/{+path}","compare_url":"https://api.github.com/repos/laravel/framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laravel/framework/merges","archive_url":"https://api.github.com/repos/laravel/framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laravel/framework/downloads","issues_url":"https://api.github.com/repos/laravel/framework/issues{/number}","pulls_url":"https://api.github.com/repos/laravel/framework/pulls{/number}","milestones_url":"https://api.github.com/repos/laravel/framework/milestones{/number}","notifications_url":"https://api.github.com/repos/laravel/framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laravel/framework/labels{/name}","releases_url":"https://api.github.com/repos/laravel/framework/releases{/id}","created_at":"2013-01-10T21:27:28Z","updated_at":"2016-01-01T11:29:47Z","pushed_at":"2016-01-01T17:25:09Z","git_url":"git://github.com/laravel/framework.git","ssh_url":"git@github.com:laravel/framework.git","clone_url":"https://github.com/laravel/framework.git","svn_url":"https://github.com/laravel/framework","homepage":"http://laravel.com","size":33462,"stargazers_count":4555,"watchers_count":4555,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2649,"mirror_url":null,"open_issues_count":33,"forks":2649,"open_issues":33,"watchers":4555,"default_branch":"5.2"}},"_links":{"self":{"href":"https://api.github.com/repos/laravel/framework/pulls/11646"},"html":{"href":"https://github.com/laravel/framework/pull/11646"},"issue":{"href":"https://api.github.com/repos/laravel/framework/issues/11646"},"comments":{"href":"https://api.github.com/repos/laravel/framework/issues/11646/comments"},"review_comments":{"href":"https://api.github.com/repos/laravel/framework/pulls/11646/comments"},"review_comment":{"href":"https://api.github.com/repos/laravel/framework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/laravel/framework/pulls/11646/commits"},"statuses":{"href":"https://api.github.com/repos/laravel/framework/statuses/d8ce94b7e835a314edb325f380910e0b126d192d"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"taylorotwell","id":463230,"avatar_url":"https://avatars.githubusercontent.com/u/463230?v=3","gravatar_id":"","url":"https://api.github.com/users/taylorotwell","html_url":"https://github.com/taylorotwell","followers_url":"https://api.github.com/users/taylorotwell/followers","following_url":"https://api.github.com/users/taylorotwell/following{/other_user}","gists_url":"https://api.github.com/users/taylorotwell/gists{/gist_id}","starred_url":"https://api.github.com/users/taylorotwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taylorotwell/subscriptions","organizations_url":"https://api.github.com/users/taylorotwell/orgs","repos_url":"https://api.github.com/users/taylorotwell/repos","events_url":"https://api.github.com/users/taylorotwell/events{/privacy}","received_events_url":"https://api.github.com/users/taylorotwell/received_events","type":"User","site_admin":false},"comments":4,"review_comments":0,"commits":2,"additions":12,"deletions":5,"changed_files":3}}