{"action":"created","comment":{"url":"https://api.github.com/repos/google/agera/pulls/comments/64152480","id":64152480,"diff_hunk":"@@ -142,20 +142,23 @@ protected void observableDeactivated() {\n   @Override\n   public void update() {\n     maybeCancelFlow(concurrentUpdateConfig, true);\n-    maybeStartFlow();\n+    maybeStartFlow(false);\n   }\n \n   /**\n    * Called on the worker looper thread. Starts the data processing flow if it's not running. This\n    * also cancels the lazily-executed part of the flow if the run state is \"paused at lazy\".\n    */\n-  void maybeStartFlow() {\n+  void maybeStartFlow(final boolean restartNeeded) {\n     synchronized (this) {\n       if (runState == IDLE || runState == PAUSED_AT_GO_LAZY) {\n         runState = RUNNING;\n         lastDirectiveIndex = -1; // this could be pointing at the goLazy directive\n-        restartNeeded = false;\n+        this.restartNeeded = false;\n       } else {\n+        if (runState == CANCEL_REQUESTED) {\n+          this.restartNeeded |= restartNeeded;\n+        }\n         return; // flow already running, do not continue.","path":"agera/src/main/java/com/google/android/agera/CompiledRepository.java","position":33,"original_position":33,"commit_id":"9f8847d5d1c34e38177c19ba427bb9446c5afaca","original_commit_id":"9f8847d5d1c34e38177c19ba427bb9446c5afaca","user":{"login":"maxtroy","id":16337072,"avatar_url":"https://avatars.githubusercontent.com/u/16337072?v=3","gravatar_id":"","url":"https://api.github.com/users/maxtroy","html_url":"https://github.com/maxtroy","followers_url":"https://api.github.com/users/maxtroy/followers","following_url":"https://api.github.com/users/maxtroy/following{/other_user}","gists_url":"https://api.github.com/users/maxtroy/gists{/gist_id}","starred_url":"https://api.github.com/users/maxtroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxtroy/subscriptions","organizations_url":"https://api.github.com/users/maxtroy/orgs","repos_url":"https://api.github.com/users/maxtroy/repos","events_url":"https://api.github.com/users/maxtroy/events{/privacy}","received_events_url":"https://api.github.com/users/maxtroy/received_events","type":"User","site_admin":false},"body":"Looking at this original comment, I think the race condition is more serious (and frequent) than you think (quoting your keyword \"rarely occurring\").\r\n\r\nThe flow that concerns me:\r\n\r\nsome event -> update() -> maybeStartFlow(false) -> \"flow already running, do not continue\".\r\n\r\nBut what if the flow is under a lengthy process (state == RUNNING), but the computation is based on some outdated value retrieved before the event?\r\n\r\nI think, with relatively high confidence, that rescheduling restart is unconditional within this else-block. This might cause two or three passes of the flow to stabilize the repository, but we should assume any caching/deduping be handled gracefully by the operators already, anyway, so the cost of this stabilizing isn't that high.\r\n\r\nIf you agree too, then let's chat to discuss the perfect fix. I'm thinking maybe both `maybeStartFlow()` and `maybeCancelFlow()` can be free of the boolean parameters -- `maybeCancelFlow()` will only set restartNeeded to false, and maybeStartFlow() will only set restartNeeded to true, when appropriate.","created_at":"2016-05-22T16:32:16Z","updated_at":"2016-05-22T16:32:16Z","html_url":"https://github.com/google/agera/pull/46#discussion_r64152480","pull_request_url":"https://api.github.com/repos/google/agera/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/google/agera/pulls/comments/64152480"},"html":{"href":"https://github.com/google/agera/pull/46#discussion_r64152480"},"pull_request":{"href":"https://api.github.com/repos/google/agera/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/google/agera/pulls/46","id":69947258,"html_url":"https://github.com/google/agera/pull/46","diff_url":"https://github.com/google/agera/pull/46.diff","patch_url":"https://github.com/google/agera/pull/46.patch","issue_url":"https://api.github.com/repos/google/agera/issues/46","number":46,"state":"open","locked":false,"title":"Fixed compiled repository race condition","user":{"login":"ernstsson","id":378389,"avatar_url":"https://avatars.githubusercontent.com/u/378389?v=3","gravatar_id":"","url":"https://api.github.com/users/ernstsson","html_url":"https://github.com/ernstsson","followers_url":"https://api.github.com/users/ernstsson/followers","following_url":"https://api.github.com/users/ernstsson/following{/other_user}","gists_url":"https://api.github.com/users/ernstsson/gists{/gist_id}","starred_url":"https://api.github.com/users/ernstsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernstsson/subscriptions","organizations_url":"https://api.github.com/users/ernstsson/orgs","repos_url":"https://api.github.com/users/ernstsson/repos","events_url":"https://api.github.com/users/ernstsson/events{/privacy}","received_events_url":"https://api.github.com/users/ernstsson/received_events","type":"User","site_admin":false},"body":"(Rarely) occurring when rapidly activating/deactivating compiled\r\nrepositories with cancellation policy","created_at":"2016-05-13T06:06:07Z","updated_at":"2016-05-22T16:32:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"409567bae946f8d2e8bb03a37618709e175c1409","assignee":{"login":"maxtroy","id":16337072,"avatar_url":"https://avatars.githubusercontent.com/u/16337072?v=3","gravatar_id":"","url":"https://api.github.com/users/maxtroy","html_url":"https://github.com/maxtroy","followers_url":"https://api.github.com/users/maxtroy/followers","following_url":"https://api.github.com/users/maxtroy/following{/other_user}","gists_url":"https://api.github.com/users/maxtroy/gists{/gist_id}","starred_url":"https://api.github.com/users/maxtroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxtroy/subscriptions","organizations_url":"https://api.github.com/users/maxtroy/orgs","repos_url":"https://api.github.com/users/maxtroy/repos","events_url":"https://api.github.com/users/maxtroy/events{/privacy}","received_events_url":"https://api.github.com/users/maxtroy/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/google/agera/milestones/1","html_url":"https://github.com/google/agera/milestones/v1.1","labels_url":"https://api.github.com/repos/google/agera/milestones/1/labels","id":1778111,"number":1,"title":"v1.1","description":null,"creator":{"login":"ernstsson","id":378389,"avatar_url":"https://avatars.githubusercontent.com/u/378389?v=3","gravatar_id":"","url":"https://api.github.com/users/ernstsson","html_url":"https://github.com/ernstsson","followers_url":"https://api.github.com/users/ernstsson/followers","following_url":"https://api.github.com/users/ernstsson/following{/other_user}","gists_url":"https://api.github.com/users/ernstsson/gists{/gist_id}","starred_url":"https://api.github.com/users/ernstsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernstsson/subscriptions","organizations_url":"https://api.github.com/users/ernstsson/orgs","repos_url":"https://api.github.com/users/ernstsson/repos","events_url":"https://api.github.com/users/ernstsson/events{/privacy}","received_events_url":"https://api.github.com/users/ernstsson/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-05-20T06:08:54Z","updated_at":"2016-05-20T08:43:56Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/google/agera/pulls/46/commits","review_comments_url":"https://api.github.com/repos/google/agera/pulls/46/comments","review_comment_url":"https://api.github.com/repos/google/agera/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/agera/issues/46/comments","statuses_url":"https://api.github.com/repos/google/agera/statuses/9f8847d5d1c34e38177c19ba427bb9446c5afaca","head":{"label":"ernstsson:cancellationfix","ref":"cancellationfix","sha":"9f8847d5d1c34e38177c19ba427bb9446c5afaca","user":{"login":"ernstsson","id":378389,"avatar_url":"https://avatars.githubusercontent.com/u/378389?v=3","gravatar_id":"","url":"https://api.github.com/users/ernstsson","html_url":"https://github.com/ernstsson","followers_url":"https://api.github.com/users/ernstsson/followers","following_url":"https://api.github.com/users/ernstsson/following{/other_user}","gists_url":"https://api.github.com/users/ernstsson/gists{/gist_id}","starred_url":"https://api.github.com/users/ernstsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernstsson/subscriptions","organizations_url":"https://api.github.com/users/ernstsson/orgs","repos_url":"https://api.github.com/users/ernstsson/repos","events_url":"https://api.github.com/users/ernstsson/events{/privacy}","received_events_url":"https://api.github.com/users/ernstsson/received_events","type":"User","site_admin":false},"repo":{"id":56751789,"name":"agera","full_name":"ernstsson/agera","owner":{"login":"ernstsson","id":378389,"avatar_url":"https://avatars.githubusercontent.com/u/378389?v=3","gravatar_id":"","url":"https://api.github.com/users/ernstsson","html_url":"https://github.com/ernstsson","followers_url":"https://api.github.com/users/ernstsson/followers","following_url":"https://api.github.com/users/ernstsson/following{/other_user}","gists_url":"https://api.github.com/users/ernstsson/gists{/gist_id}","starred_url":"https://api.github.com/users/ernstsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernstsson/subscriptions","organizations_url":"https://api.github.com/users/ernstsson/orgs","repos_url":"https://api.github.com/users/ernstsson/repos","events_url":"https://api.github.com/users/ernstsson/events{/privacy}","received_events_url":"https://api.github.com/users/ernstsson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ernstsson/agera","description":"Reactive Programming for Android","fork":true,"url":"https://api.github.com/repos/ernstsson/agera","forks_url":"https://api.github.com/repos/ernstsson/agera/forks","keys_url":"https://api.github.com/repos/ernstsson/agera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ernstsson/agera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ernstsson/agera/teams","hooks_url":"https://api.github.com/repos/ernstsson/agera/hooks","issue_events_url":"https://api.github.com/repos/ernstsson/agera/issues/events{/number}","events_url":"https://api.github.com/repos/ernstsson/agera/events","assignees_url":"https://api.github.com/repos/ernstsson/agera/assignees{/user}","branches_url":"https://api.github.com/repos/ernstsson/agera/branches{/branch}","tags_url":"https://api.github.com/repos/ernstsson/agera/tags","blobs_url":"https://api.github.com/repos/ernstsson/agera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ernstsson/agera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ernstsson/agera/git/refs{/sha}","trees_url":"https://api.github.com/repos/ernstsson/agera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ernstsson/agera/statuses/{sha}","languages_url":"https://api.github.com/repos/ernstsson/agera/languages","stargazers_url":"https://api.github.com/repos/ernstsson/agera/stargazers","contributors_url":"https://api.github.com/repos/ernstsson/agera/contributors","subscribers_url":"https://api.github.com/repos/ernstsson/agera/subscribers","subscription_url":"https://api.github.com/repos/ernstsson/agera/subscription","commits_url":"https://api.github.com/repos/ernstsson/agera/commits{/sha}","git_commits_url":"https://api.github.com/repos/ernstsson/agera/git/commits{/sha}","comments_url":"https://api.github.com/repos/ernstsson/agera/comments{/number}","issue_comment_url":"https://api.github.com/repos/ernstsson/agera/issues/comments{/number}","contents_url":"https://api.github.com/repos/ernstsson/agera/contents/{+path}","compare_url":"https://api.github.com/repos/ernstsson/agera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ernstsson/agera/merges","archive_url":"https://api.github.com/repos/ernstsson/agera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ernstsson/agera/downloads","issues_url":"https://api.github.com/repos/ernstsson/agera/issues{/number}","pulls_url":"https://api.github.com/repos/ernstsson/agera/pulls{/number}","milestones_url":"https://api.github.com/repos/ernstsson/agera/milestones{/number}","notifications_url":"https://api.github.com/repos/ernstsson/agera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ernstsson/agera/labels{/name}","releases_url":"https://api.github.com/repos/ernstsson/agera/releases{/id}","deployments_url":"https://api.github.com/repos/ernstsson/agera/deployments","created_at":"2016-04-21T07:25:16Z","updated_at":"2016-05-13T06:59:33Z","pushed_at":"2016-05-20T10:08:44Z","git_url":"git://github.com/ernstsson/agera.git","ssh_url":"git@github.com:ernstsson/agera.git","clone_url":"https://github.com/ernstsson/agera.git","svn_url":"https://github.com/ernstsson/agera","homepage":"","size":749,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"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":"master"}},"base":{"label":"google:master","ref":"master","sha":"5e518b7b05f9e7a34a314945f68deff7b2c3e334","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":48175620,"name":"agera","full_name":"google/agera","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/agera","description":"Reactive Programming for Android","fork":false,"url":"https://api.github.com/repos/google/agera","forks_url":"https://api.github.com/repos/google/agera/forks","keys_url":"https://api.github.com/repos/google/agera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/agera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/agera/teams","hooks_url":"https://api.github.com/repos/google/agera/hooks","issue_events_url":"https://api.github.com/repos/google/agera/issues/events{/number}","events_url":"https://api.github.com/repos/google/agera/events","assignees_url":"https://api.github.com/repos/google/agera/assignees{/user}","branches_url":"https://api.github.com/repos/google/agera/branches{/branch}","tags_url":"https://api.github.com/repos/google/agera/tags","blobs_url":"https://api.github.com/repos/google/agera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/agera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/agera/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/agera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/agera/statuses/{sha}","languages_url":"https://api.github.com/repos/google/agera/languages","stargazers_url":"https://api.github.com/repos/google/agera/stargazers","contributors_url":"https://api.github.com/repos/google/agera/contributors","subscribers_url":"https://api.github.com/repos/google/agera/subscribers","subscription_url":"https://api.github.com/repos/google/agera/subscription","commits_url":"https://api.github.com/repos/google/agera/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/agera/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/agera/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/agera/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/agera/contents/{+path}","compare_url":"https://api.github.com/repos/google/agera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/agera/merges","archive_url":"https://api.github.com/repos/google/agera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/agera/downloads","issues_url":"https://api.github.com/repos/google/agera/issues{/number}","pulls_url":"https://api.github.com/repos/google/agera/pulls{/number}","milestones_url":"https://api.github.com/repos/google/agera/milestones{/number}","notifications_url":"https://api.github.com/repos/google/agera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/agera/labels{/name}","releases_url":"https://api.github.com/repos/google/agera/releases{/id}","deployments_url":"https://api.github.com/repos/google/agera/deployments","created_at":"2015-12-17T13:22:58Z","updated_at":"2016-05-22T15:17:03Z","pushed_at":"2016-05-20T08:43:56Z","git_url":"git://github.com/google/agera.git","ssh_url":"git@github.com:google/agera.git","clone_url":"https://github.com/google/agera.git","svn_url":"https://github.com/google/agera","homepage":"","size":895,"stargazers_count":5016,"watchers_count":5016,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":389,"mirror_url":null,"open_issues_count":8,"forks":389,"open_issues":8,"watchers":5016,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/agera/pulls/46"},"html":{"href":"https://github.com/google/agera/pull/46"},"issue":{"href":"https://api.github.com/repos/google/agera/issues/46"},"comments":{"href":"https://api.github.com/repos/google/agera/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/google/agera/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/google/agera/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/agera/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/google/agera/statuses/9f8847d5d1c34e38177c19ba427bb9446c5afaca"}}}}
{"actor":{"display_login":"maxtroy"}}