{"action":"created","comment":{"url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/comments/66409053","id":66409053,"diff_hunk":"@@ -235,7 +238,7 @@ def acquire(alive_time, max_acquire, options)\n \n         if @cleanup_interval_count <= 0\n           connect_locked {\n-            @db[\"DELETE FROM `#{@table}` WHERE timeout <= ? AND created_at IS NULL\", now].delete\n+            @db[\"DELETE FROM `#{@table}` WHERE #{EVENT_HORIZON} < timeout && timeout <= ? AND created_at IS NULL\", now].delete","path":"lib/perfectqueue/backend/rdb_compat.rb","position":15,"original_position":15,"commit_id":"d957d25f5a75ab5f691c6feae077870547ffe1e0","original_commit_id":"d957d25f5a75ab5f691c6feae077870547ffe1e0","user":{"login":"kamipo","id":12642,"avatar_url":"https://avatars.githubusercontent.com/u/12642?v=3","gravatar_id":"","url":"https://api.github.com/users/kamipo","html_url":"https://github.com/kamipo","followers_url":"https://api.github.com/users/kamipo/followers","following_url":"https://api.github.com/users/kamipo/following{/other_user}","gists_url":"https://api.github.com/users/kamipo/gists{/gist_id}","starred_url":"https://api.github.com/users/kamipo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamipo/subscriptions","organizations_url":"https://api.github.com/users/kamipo/orgs","repos_url":"https://api.github.com/users/kamipo/repos","events_url":"https://api.github.com/users/kamipo/events{/privacy}","received_events_url":"https://api.github.com/users/kamipo/received_events","type":"User","site_admin":false},"body":"Is it better to check `EVENT_HORIZON` for acquire query?\r\n\r\n```diff\r\ndiff --git a/lib/perfectqueue/backend/rdb_compat.rb b/lib/perfectqueue/backend/rdb_compat.rb\r\nindex 6b4b6c1..8ab0364 100644\r\n--- a/lib/perfectqueue/backend/rdb_compat.rb\r\n+++ b/lib/perfectqueue/backend/rdb_compat.rb\r\n@@ -76,6 +76,7 @@ module PerfectQueue\r\n SELECT id, timeout, data, created_at, resource\r\n FROM `#{@table}`\r\n WHERE timeout <= ? AND timeout <= ? AND created_at IS NOT NULL\r\n+  AND #{EVENT_HORIZON} < timeout\r\n ORDER BY timeout ASC\r\n LIMIT ?\r\n SQL\r\n@@ -90,6 +91,7 @@ LEFT JOIN (\r\n   GROUP BY resource\r\n ) AS R ON resource = res\r\n WHERE timeout <= ? AND created_at IS NOT NULL AND (max_running-running IS NULL OR max_running-running > 0)\r\n+  AND #{EVENT_HORIZON} < timeout\r\n ORDER BY weight DESC, timeout ASC\r\n LIMIT ?\r\n SQL\r\n```","created_at":"2016-06-09T09:29:11Z","updated_at":"2016-06-09T09:29:11Z","html_url":"https://github.com/treasure-data/perfectqueue/pull/32#discussion_r66409053","pull_request_url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/comments/66409053"},"html":{"href":"https://github.com/treasure-data/perfectqueue/pull/32#discussion_r66409053"},"pull_request":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32","id":73178794,"html_url":"https://github.com/treasure-data/perfectqueue/pull/32","diff_url":"https://github.com/treasure-data/perfectqueue/pull/32.diff","patch_url":"https://github.com/treasure-data/perfectqueue/pull/32.patch","issue_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues/32","number":32,"state":"open","locked":false,"title":"Don't delete v0.8.46's finished tasks for migration","user":{"login":"nurse","id":13423,"avatar_url":"https://avatars.githubusercontent.com/u/13423?v=3","gravatar_id":"","url":"https://api.github.com/users/nurse","html_url":"https://github.com/nurse","followers_url":"https://api.github.com/users/nurse/followers","following_url":"https://api.github.com/users/nurse/following{/other_user}","gists_url":"https://api.github.com/users/nurse/gists{/gist_id}","starred_url":"https://api.github.com/users/nurse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nurse/subscriptions","organizations_url":"https://api.github.com/users/nurse/orgs","repos_url":"https://api.github.com/users/nurse/repos","events_url":"https://api.github.com/users/nurse/events{/privacy}","received_events_url":"https://api.github.com/users/nurse/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-09T09:03:09Z","updated_at":"2016-06-09T09:29:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b83103613afde7e268f824adeb54392f4219fc2b","assignee":{"login":"kamipo","id":12642,"avatar_url":"https://avatars.githubusercontent.com/u/12642?v=3","gravatar_id":"","url":"https://api.github.com/users/kamipo","html_url":"https://github.com/kamipo","followers_url":"https://api.github.com/users/kamipo/followers","following_url":"https://api.github.com/users/kamipo/following{/other_user}","gists_url":"https://api.github.com/users/kamipo/gists{/gist_id}","starred_url":"https://api.github.com/users/kamipo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamipo/subscriptions","organizations_url":"https://api.github.com/users/kamipo/orgs","repos_url":"https://api.github.com/users/kamipo/repos","events_url":"https://api.github.com/users/kamipo/events{/privacy}","received_events_url":"https://api.github.com/users/kamipo/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32/commits","review_comments_url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32/comments","review_comment_url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/comments{/number}","comments_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues/32/comments","statuses_url":"https://api.github.com/repos/treasure-data/perfectqueue/statuses/d957d25f5a75ab5f691c6feae077870547ffe1e0","head":{"label":"treasure-data:dont-delete-finished-tasks-of-v0.8.46","ref":"dont-delete-finished-tasks-of-v0.8.46","sha":"d957d25f5a75ab5f691c6feae077870547ffe1e0","user":{"login":"treasure-data","id":747746,"avatar_url":"https://avatars.githubusercontent.com/u/747746?v=3","gravatar_id":"","url":"https://api.github.com/users/treasure-data","html_url":"https://github.com/treasure-data","followers_url":"https://api.github.com/users/treasure-data/followers","following_url":"https://api.github.com/users/treasure-data/following{/other_user}","gists_url":"https://api.github.com/users/treasure-data/gists{/gist_id}","starred_url":"https://api.github.com/users/treasure-data/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treasure-data/subscriptions","organizations_url":"https://api.github.com/users/treasure-data/orgs","repos_url":"https://api.github.com/users/treasure-data/repos","events_url":"https://api.github.com/users/treasure-data/events{/privacy}","received_events_url":"https://api.github.com/users/treasure-data/received_events","type":"Organization","site_admin":false},"repo":{"id":2255601,"name":"perfectqueue","full_name":"treasure-data/perfectqueue","owner":{"login":"treasure-data","id":747746,"avatar_url":"https://avatars.githubusercontent.com/u/747746?v=3","gravatar_id":"","url":"https://api.github.com/users/treasure-data","html_url":"https://github.com/treasure-data","followers_url":"https://api.github.com/users/treasure-data/followers","following_url":"https://api.github.com/users/treasure-data/following{/other_user}","gists_url":"https://api.github.com/users/treasure-data/gists{/gist_id}","starred_url":"https://api.github.com/users/treasure-data/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treasure-data/subscriptions","organizations_url":"https://api.github.com/users/treasure-data/orgs","repos_url":"https://api.github.com/users/treasure-data/repos","events_url":"https://api.github.com/users/treasure-data/events{/privacy}","received_events_url":"https://api.github.com/users/treasure-data/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/treasure-data/perfectqueue","description":"Highly available distributed queue built on RDBMS","fork":false,"url":"https://api.github.com/repos/treasure-data/perfectqueue","forks_url":"https://api.github.com/repos/treasure-data/perfectqueue/forks","keys_url":"https://api.github.com/repos/treasure-data/perfectqueue/keys{/key_id}","collaborators_url":"https://api.github.com/repos/treasure-data/perfectqueue/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/treasure-data/perfectqueue/teams","hooks_url":"https://api.github.com/repos/treasure-data/perfectqueue/hooks","issue_events_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues/events{/number}","events_url":"https://api.github.com/repos/treasure-data/perfectqueue/events","assignees_url":"https://api.github.com/repos/treasure-data/perfectqueue/assignees{/user}","branches_url":"https://api.github.com/repos/treasure-data/perfectqueue/branches{/branch}","tags_url":"https://api.github.com/repos/treasure-data/perfectqueue/tags","blobs_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/refs{/sha}","trees_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/trees{/sha}","statuses_url":"https://api.github.com/repos/treasure-data/perfectqueue/statuses/{sha}","languages_url":"https://api.github.com/repos/treasure-data/perfectqueue/languages","stargazers_url":"https://api.github.com/repos/treasure-data/perfectqueue/stargazers","contributors_url":"https://api.github.com/repos/treasure-data/perfectqueue/contributors","subscribers_url":"https://api.github.com/repos/treasure-data/perfectqueue/subscribers","subscription_url":"https://api.github.com/repos/treasure-data/perfectqueue/subscription","commits_url":"https://api.github.com/repos/treasure-data/perfectqueue/commits{/sha}","git_commits_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/commits{/sha}","comments_url":"https://api.github.com/repos/treasure-data/perfectqueue/comments{/number}","issue_comment_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues/comments{/number}","contents_url":"https://api.github.com/repos/treasure-data/perfectqueue/contents/{+path}","compare_url":"https://api.github.com/repos/treasure-data/perfectqueue/compare/{base}...{head}","merges_url":"https://api.github.com/repos/treasure-data/perfectqueue/merges","archive_url":"https://api.github.com/repos/treasure-data/perfectqueue/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/treasure-data/perfectqueue/downloads","issues_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues{/number}","pulls_url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls{/number}","milestones_url":"https://api.github.com/repos/treasure-data/perfectqueue/milestones{/number}","notifications_url":"https://api.github.com/repos/treasure-data/perfectqueue/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/treasure-data/perfectqueue/labels{/name}","releases_url":"https://api.github.com/repos/treasure-data/perfectqueue/releases{/id}","deployments_url":"https://api.github.com/repos/treasure-data/perfectqueue/deployments","created_at":"2011-08-23T14:27:29Z","updated_at":"2016-05-28T09:44:03Z","pushed_at":"2016-06-09T09:03:09Z","git_url":"git://github.com/treasure-data/perfectqueue.git","ssh_url":"git@github.com:treasure-data/perfectqueue.git","clone_url":"https://github.com/treasure-data/perfectqueue.git","svn_url":"https://github.com/treasure-data/perfectqueue","homepage":"","size":321,"stargazers_count":76,"watchers_count":76,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":3,"forks":4,"open_issues":3,"watchers":76,"default_branch":"master"}},"base":{"label":"treasure-data:stable-0.8.44","ref":"stable-0.8.44","sha":"6b5e32a610aaf074a838a0cfee6d26a757e00194","user":{"login":"treasure-data","id":747746,"avatar_url":"https://avatars.githubusercontent.com/u/747746?v=3","gravatar_id":"","url":"https://api.github.com/users/treasure-data","html_url":"https://github.com/treasure-data","followers_url":"https://api.github.com/users/treasure-data/followers","following_url":"https://api.github.com/users/treasure-data/following{/other_user}","gists_url":"https://api.github.com/users/treasure-data/gists{/gist_id}","starred_url":"https://api.github.com/users/treasure-data/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treasure-data/subscriptions","organizations_url":"https://api.github.com/users/treasure-data/orgs","repos_url":"https://api.github.com/users/treasure-data/repos","events_url":"https://api.github.com/users/treasure-data/events{/privacy}","received_events_url":"https://api.github.com/users/treasure-data/received_events","type":"Organization","site_admin":false},"repo":{"id":2255601,"name":"perfectqueue","full_name":"treasure-data/perfectqueue","owner":{"login":"treasure-data","id":747746,"avatar_url":"https://avatars.githubusercontent.com/u/747746?v=3","gravatar_id":"","url":"https://api.github.com/users/treasure-data","html_url":"https://github.com/treasure-data","followers_url":"https://api.github.com/users/treasure-data/followers","following_url":"https://api.github.com/users/treasure-data/following{/other_user}","gists_url":"https://api.github.com/users/treasure-data/gists{/gist_id}","starred_url":"https://api.github.com/users/treasure-data/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treasure-data/subscriptions","organizations_url":"https://api.github.com/users/treasure-data/orgs","repos_url":"https://api.github.com/users/treasure-data/repos","events_url":"https://api.github.com/users/treasure-data/events{/privacy}","received_events_url":"https://api.github.com/users/treasure-data/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/treasure-data/perfectqueue","description":"Highly available distributed queue built on RDBMS","fork":false,"url":"https://api.github.com/repos/treasure-data/perfectqueue","forks_url":"https://api.github.com/repos/treasure-data/perfectqueue/forks","keys_url":"https://api.github.com/repos/treasure-data/perfectqueue/keys{/key_id}","collaborators_url":"https://api.github.com/repos/treasure-data/perfectqueue/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/treasure-data/perfectqueue/teams","hooks_url":"https://api.github.com/repos/treasure-data/perfectqueue/hooks","issue_events_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues/events{/number}","events_url":"https://api.github.com/repos/treasure-data/perfectqueue/events","assignees_url":"https://api.github.com/repos/treasure-data/perfectqueue/assignees{/user}","branches_url":"https://api.github.com/repos/treasure-data/perfectqueue/branches{/branch}","tags_url":"https://api.github.com/repos/treasure-data/perfectqueue/tags","blobs_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/refs{/sha}","trees_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/trees{/sha}","statuses_url":"https://api.github.com/repos/treasure-data/perfectqueue/statuses/{sha}","languages_url":"https://api.github.com/repos/treasure-data/perfectqueue/languages","stargazers_url":"https://api.github.com/repos/treasure-data/perfectqueue/stargazers","contributors_url":"https://api.github.com/repos/treasure-data/perfectqueue/contributors","subscribers_url":"https://api.github.com/repos/treasure-data/perfectqueue/subscribers","subscription_url":"https://api.github.com/repos/treasure-data/perfectqueue/subscription","commits_url":"https://api.github.com/repos/treasure-data/perfectqueue/commits{/sha}","git_commits_url":"https://api.github.com/repos/treasure-data/perfectqueue/git/commits{/sha}","comments_url":"https://api.github.com/repos/treasure-data/perfectqueue/comments{/number}","issue_comment_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues/comments{/number}","contents_url":"https://api.github.com/repos/treasure-data/perfectqueue/contents/{+path}","compare_url":"https://api.github.com/repos/treasure-data/perfectqueue/compare/{base}...{head}","merges_url":"https://api.github.com/repos/treasure-data/perfectqueue/merges","archive_url":"https://api.github.com/repos/treasure-data/perfectqueue/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/treasure-data/perfectqueue/downloads","issues_url":"https://api.github.com/repos/treasure-data/perfectqueue/issues{/number}","pulls_url":"https://api.github.com/repos/treasure-data/perfectqueue/pulls{/number}","milestones_url":"https://api.github.com/repos/treasure-data/perfectqueue/milestones{/number}","notifications_url":"https://api.github.com/repos/treasure-data/perfectqueue/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/treasure-data/perfectqueue/labels{/name}","releases_url":"https://api.github.com/repos/treasure-data/perfectqueue/releases{/id}","deployments_url":"https://api.github.com/repos/treasure-data/perfectqueue/deployments","created_at":"2011-08-23T14:27:29Z","updated_at":"2016-05-28T09:44:03Z","pushed_at":"2016-06-09T09:03:09Z","git_url":"git://github.com/treasure-data/perfectqueue.git","ssh_url":"git@github.com:treasure-data/perfectqueue.git","clone_url":"https://github.com/treasure-data/perfectqueue.git","svn_url":"https://github.com/treasure-data/perfectqueue","homepage":"","size":321,"stargazers_count":76,"watchers_count":76,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":3,"forks":4,"open_issues":3,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32"},"html":{"href":"https://github.com/treasure-data/perfectqueue/pull/32"},"issue":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/issues/32"},"comments":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/treasure-data/perfectqueue/statuses/d957d25f5a75ab5f691c6feae077870547ffe1e0"}}}}
{"actor":{"display_login":"kamipo"}}