{"action":"created","comment":{"url":"https://api.github.com/repos/treasure-data/digdag/pulls/comments/77262941","id":77262941,"diff_hunk":"@@ -443,51 +446,54 @@ public StoredWorkflowDefinition insertWorkflowDefinition(int projId, int revId,\n         }\n \n         @Override\n-        public void updateSchedules(int projId, List<Schedule> schedules)\n+        public void updateSchedules(int projId, List<Schedule> schedules,\n+                ScheduleUpdateAction func)\n             throws ResourceConflictException\n         {\n-            Map<String, Integer> oldNames = idNameListToHashMap(dao.getScheduleNames(projId));\n+            Map<String, Integer> oldScheduleNames = idNameListToHashMap(dao.getScheduleNames(projId));\n+\n+            // Concurrent call of updateSchedules doesn't happen because having\n+            // ProjectControlStore means that the project is locked.\n+            //\n+            // However, ScheduleExecutor modifies schedules without locking the\n+            // project. Instead, ScheduleExecutor locks schedules. To avoid\n+            // concurrent update of schedules, here needs to lock schedules\n+            // before UPDATE.\n \n             for (Schedule schedule : schedules) {\n-                if (oldNames.containsKey(schedule.getWorkflowName())) {\n-                    // found the same name. overwriting workflow_definition_id\n-                    int n = handle.createStatement(\n-                            \"update schedules\" +\n-                            \" set workflow_definition_id = :workflowDefinitionId, updated_at = now()\" +\n-                            // TODO should here update next_run_time nad next_schedule_time?\n-                            \" where id = :id\"\n-                        )\n-                        .bind(\"workflowDefinitionId\", schedule.getWorkflowDefinitionId())\n-                        .bind(\"id\", oldNames.get(schedule.getWorkflowName()))\n-                        .execute();\n-                    if (n <= 0) {\n-                        // TODO exception?\n+                Integer matchingSchedId = oldScheduleNames.get(schedule.getWorkflowName());","path":"digdag-core/src/main/java/io/digdag/core/database/DatabaseProjectStoreManager.java","position":51,"original_position":51,"commit_id":"32e4d5122eec9c1d7758dd5f3868f25b691a93d5","original_commit_id":"32e4d5122eec9c1d7758dd5f3868f25b691a93d5","user":{"login":"frsyuki","id":40720,"avatar_url":"https://avatars.githubusercontent.com/u/40720?v=3","gravatar_id":"","url":"https://api.github.com/users/frsyuki","html_url":"https://github.com/frsyuki","followers_url":"https://api.github.com/users/frsyuki/followers","following_url":"https://api.github.com/users/frsyuki/following{/other_user}","gists_url":"https://api.github.com/users/frsyuki/gists{/gist_id}","starred_url":"https://api.github.com/users/frsyuki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frsyuki/subscriptions","organizations_url":"https://api.github.com/users/frsyuki/orgs","repos_url":"https://api.github.com/users/frsyuki/repos","events_url":"https://api.github.com/users/frsyuki/events{/privacy}","received_events_url":"https://api.github.com/users/frsyuki/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2016-09-01T22:06:58Z","updated_at":"2016-09-01T22:06:58Z","html_url":"https://github.com/treasure-data/digdag/pull/251#discussion_r77262941","pull_request_url":"https://api.github.com/repos/treasure-data/digdag/pulls/251","_links":{"self":{"href":"https://api.github.com/repos/treasure-data/digdag/pulls/comments/77262941"},"html":{"href":"https://github.com/treasure-data/digdag/pull/251#discussion_r77262941"},"pull_request":{"href":"https://api.github.com/repos/treasure-data/digdag/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/treasure-data/digdag/pulls/251","id":83543714,"html_url":"https://github.com/treasure-data/digdag/pull/251","diff_url":"https://github.com/treasure-data/digdag/pull/251.diff","patch_url":"https://github.com/treasure-data/digdag/pull/251.patch","issue_url":"https://api.github.com/repos/treasure-data/digdag/issues/251","number":251,"state":"open","locked":false,"title":"Updating schedule should recalculate next session time","user":{"login":"frsyuki","id":40720,"avatar_url":"https://avatars.githubusercontent.com/u/40720?v=3","gravatar_id":"","url":"https://api.github.com/users/frsyuki","html_url":"https://github.com/frsyuki","followers_url":"https://api.github.com/users/frsyuki/followers","following_url":"https://api.github.com/users/frsyuki/following{/other_user}","gists_url":"https://api.github.com/users/frsyuki/gists{/gist_id}","starred_url":"https://api.github.com/users/frsyuki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frsyuki/subscriptions","organizations_url":"https://api.github.com/users/frsyuki/orgs","repos_url":"https://api.github.com/users/frsyuki/repos","events_url":"https://api.github.com/users/frsyuki/events{/privacy}","received_events_url":"https://api.github.com/users/frsyuki/received_events","type":"User","site_admin":false},"body":"Schedule was not recalculated when a new revision is pushed. This\r\nbecomes a problem when a previous revision has a daily schedule by\r\nacccident and new revision fixes it to hourly schedule.","created_at":"2016-08-31T22:52:52Z","updated_at":"2016-09-01T22:06:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d74962fc25f69bb880c26d2f2b7471da2b0536e5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/treasure-data/digdag/pulls/251/commits","review_comments_url":"https://api.github.com/repos/treasure-data/digdag/pulls/251/comments","review_comment_url":"https://api.github.com/repos/treasure-data/digdag/pulls/comments{/number}","comments_url":"https://api.github.com/repos/treasure-data/digdag/issues/251/comments","statuses_url":"https://api.github.com/repos/treasure-data/digdag/statuses/32e4d5122eec9c1d7758dd5f3868f25b691a93d5","head":{"label":"treasure-data:schedule-update-fix","ref":"schedule-update-fix","sha":"32e4d5122eec9c1d7758dd5f3868f25b691a93d5","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":42751387,"name":"digdag","full_name":"treasure-data/digdag","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/digdag","description":"Workload Automation System","fork":false,"url":"https://api.github.com/repos/treasure-data/digdag","forks_url":"https://api.github.com/repos/treasure-data/digdag/forks","keys_url":"https://api.github.com/repos/treasure-data/digdag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/treasure-data/digdag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/treasure-data/digdag/teams","hooks_url":"https://api.github.com/repos/treasure-data/digdag/hooks","issue_events_url":"https://api.github.com/repos/treasure-data/digdag/issues/events{/number}","events_url":"https://api.github.com/repos/treasure-data/digdag/events","assignees_url":"https://api.github.com/repos/treasure-data/digdag/assignees{/user}","branches_url":"https://api.github.com/repos/treasure-data/digdag/branches{/branch}","tags_url":"https://api.github.com/repos/treasure-data/digdag/tags","blobs_url":"https://api.github.com/repos/treasure-data/digdag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/treasure-data/digdag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/treasure-data/digdag/git/refs{/sha}","trees_url":"https://api.github.com/repos/treasure-data/digdag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/treasure-data/digdag/statuses/{sha}","languages_url":"https://api.github.com/repos/treasure-data/digdag/languages","stargazers_url":"https://api.github.com/repos/treasure-data/digdag/stargazers","contributors_url":"https://api.github.com/repos/treasure-data/digdag/contributors","subscribers_url":"https://api.github.com/repos/treasure-data/digdag/subscribers","subscription_url":"https://api.github.com/repos/treasure-data/digdag/subscription","commits_url":"https://api.github.com/repos/treasure-data/digdag/commits{/sha}","git_commits_url":"https://api.github.com/repos/treasure-data/digdag/git/commits{/sha}","comments_url":"https://api.github.com/repos/treasure-data/digdag/comments{/number}","issue_comment_url":"https://api.github.com/repos/treasure-data/digdag/issues/comments{/number}","contents_url":"https://api.github.com/repos/treasure-data/digdag/contents/{+path}","compare_url":"https://api.github.com/repos/treasure-data/digdag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/treasure-data/digdag/merges","archive_url":"https://api.github.com/repos/treasure-data/digdag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/treasure-data/digdag/downloads","issues_url":"https://api.github.com/repos/treasure-data/digdag/issues{/number}","pulls_url":"https://api.github.com/repos/treasure-data/digdag/pulls{/number}","milestones_url":"https://api.github.com/repos/treasure-data/digdag/milestones{/number}","notifications_url":"https://api.github.com/repos/treasure-data/digdag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/treasure-data/digdag/labels{/name}","releases_url":"https://api.github.com/repos/treasure-data/digdag/releases{/id}","deployments_url":"https://api.github.com/repos/treasure-data/digdag/deployments","created_at":"2015-09-18T23:18:08Z","updated_at":"2016-08-29T07:27:22Z","pushed_at":"2016-09-01T21:31:02Z","git_url":"git://github.com/treasure-data/digdag.git","ssh_url":"git@github.com:treasure-data/digdag.git","clone_url":"https://github.com/treasure-data/digdag.git","svn_url":"https://github.com/treasure-data/digdag","homepage":"http://www.digdag.io/","size":3746,"stargazers_count":202,"watchers_count":202,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":39,"forks":27,"open_issues":39,"watchers":202,"default_branch":"master"}},"base":{"label":"treasure-data:master","ref":"master","sha":"233486b8421cf5632a965e2db1ee0a4e6416cb37","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":42751387,"name":"digdag","full_name":"treasure-data/digdag","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/digdag","description":"Workload Automation System","fork":false,"url":"https://api.github.com/repos/treasure-data/digdag","forks_url":"https://api.github.com/repos/treasure-data/digdag/forks","keys_url":"https://api.github.com/repos/treasure-data/digdag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/treasure-data/digdag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/treasure-data/digdag/teams","hooks_url":"https://api.github.com/repos/treasure-data/digdag/hooks","issue_events_url":"https://api.github.com/repos/treasure-data/digdag/issues/events{/number}","events_url":"https://api.github.com/repos/treasure-data/digdag/events","assignees_url":"https://api.github.com/repos/treasure-data/digdag/assignees{/user}","branches_url":"https://api.github.com/repos/treasure-data/digdag/branches{/branch}","tags_url":"https://api.github.com/repos/treasure-data/digdag/tags","blobs_url":"https://api.github.com/repos/treasure-data/digdag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/treasure-data/digdag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/treasure-data/digdag/git/refs{/sha}","trees_url":"https://api.github.com/repos/treasure-data/digdag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/treasure-data/digdag/statuses/{sha}","languages_url":"https://api.github.com/repos/treasure-data/digdag/languages","stargazers_url":"https://api.github.com/repos/treasure-data/digdag/stargazers","contributors_url":"https://api.github.com/repos/treasure-data/digdag/contributors","subscribers_url":"https://api.github.com/repos/treasure-data/digdag/subscribers","subscription_url":"https://api.github.com/repos/treasure-data/digdag/subscription","commits_url":"https://api.github.com/repos/treasure-data/digdag/commits{/sha}","git_commits_url":"https://api.github.com/repos/treasure-data/digdag/git/commits{/sha}","comments_url":"https://api.github.com/repos/treasure-data/digdag/comments{/number}","issue_comment_url":"https://api.github.com/repos/treasure-data/digdag/issues/comments{/number}","contents_url":"https://api.github.com/repos/treasure-data/digdag/contents/{+path}","compare_url":"https://api.github.com/repos/treasure-data/digdag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/treasure-data/digdag/merges","archive_url":"https://api.github.com/repos/treasure-data/digdag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/treasure-data/digdag/downloads","issues_url":"https://api.github.com/repos/treasure-data/digdag/issues{/number}","pulls_url":"https://api.github.com/repos/treasure-data/digdag/pulls{/number}","milestones_url":"https://api.github.com/repos/treasure-data/digdag/milestones{/number}","notifications_url":"https://api.github.com/repos/treasure-data/digdag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/treasure-data/digdag/labels{/name}","releases_url":"https://api.github.com/repos/treasure-data/digdag/releases{/id}","deployments_url":"https://api.github.com/repos/treasure-data/digdag/deployments","created_at":"2015-09-18T23:18:08Z","updated_at":"2016-08-29T07:27:22Z","pushed_at":"2016-09-01T21:31:02Z","git_url":"git://github.com/treasure-data/digdag.git","ssh_url":"git@github.com:treasure-data/digdag.git","clone_url":"https://github.com/treasure-data/digdag.git","svn_url":"https://github.com/treasure-data/digdag","homepage":"http://www.digdag.io/","size":3746,"stargazers_count":202,"watchers_count":202,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":39,"forks":27,"open_issues":39,"watchers":202,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/treasure-data/digdag/pulls/251"},"html":{"href":"https://github.com/treasure-data/digdag/pull/251"},"issue":{"href":"https://api.github.com/repos/treasure-data/digdag/issues/251"},"comments":{"href":"https://api.github.com/repos/treasure-data/digdag/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/treasure-data/digdag/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/treasure-data/digdag/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/treasure-data/digdag/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/treasure-data/digdag/statuses/32e4d5122eec9c1d7758dd5f3868f25b691a93d5"}}}}
{"actor":{"display_login":"frsyuki"}}