{"action":"created","comment":{"url":"https://api.github.com/repos/blevesearch/bleve/pulls/comments/170340641","pull_request_review_id":99020544,"id":170340641,"diff_hunk":"@@ -136,15 +141,55 @@ OUTER:\n \t\tcase <-w.notifyCh:\n \t\t\t// woken up, next loop should pick up work\n \t\t\tcontinue OUTER\n-\t\tcase ew := <-s.persisterNotifier:\n+\t\tcase ew = <-s.persisterNotifier:\n \t\t\t// if the watchers are already caught up then let them wait,\n \t\t\t// else let them continue to do the catch up\n \t\t\tpersistWatchers = append(persistWatchers, ew)\n-\t\t\tnotifyWatchers()\n \t\t}\n \t}\n }\n \n+func notifyMergeWatchers(lastPersistedEpoch uint64,\n+\tpersistWatchers []*epochWatcher) []*epochWatcher {\n+\tvar watchersNext []*epochWatcher\n+\tfor _, w := range persistWatchers {\n+\t\tif w.epoch < lastPersistedEpoch {\n+\t\t\tclose(w.notifyCh)\n+\t\t} else {\n+\t\t\twatchersNext = append(watchersNext, w)\n+\t\t}\n+\t}\n+\treturn watchersNext\n+}\n+\n+func (s *Scorch) pausePersisterForMergerCatchUp(lastPersistedEpoch uint64, lastMergedEpoch *uint64,\n+\tpersistWatchers []*epochWatcher) []*epochWatcher {\n+\n+OUTER:\n+\tfor {\n+\n+\t\t// first, let the watchers proceed if they lag behind\n+\t\tpersistWatchers = notifyMergeWatchers(lastPersistedEpoch, persistWatchers)\n+\n+\t\t// check for slow merger and pause persister until merger catch up\n+\t\tif lastPersistedEpoch > *lastMergedEpoch+epochDistance {\n+\n+\t\t\tselect {\n+\t\t\tcase <-s.closeCh:\n+\t\t\t\tbreak OUTER\n+\t\t\tcase ew := <-s.persisterNotifier:\n+\t\t\t\tpersistWatchers = append(persistWatchers, ew)\n+\t\t\t\t*lastMergedEpoch = ew.epoch\n+\t\t\t\tcontinue OUTER\n+\t\t\t}\n+\t\t} else {","path":"index/scorch/persister.go","position":105,"original_position":105,"commit_id":"a8ebf2a553c21012733a24bc950d88fb2830f955","original_commit_id":"a8ebf2a553c21012733a24bc950d88fb2830f955","user":{"login":"mschoch","id":298143,"avatar_url":"https://avatars2.githubusercontent.com/u/298143?v=4","gravatar_id":"","url":"https://api.github.com/users/mschoch","html_url":"https://github.com/mschoch","followers_url":"https://api.github.com/users/mschoch/followers","following_url":"https://api.github.com/users/mschoch/following{/other_user}","gists_url":"https://api.github.com/users/mschoch/gists{/gist_id}","starred_url":"https://api.github.com/users/mschoch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschoch/subscriptions","organizations_url":"https://api.github.com/users/mschoch/orgs","repos_url":"https://api.github.com/users/mschoch/repos","events_url":"https://api.github.com/users/mschoch/events{/privacy}","received_events_url":"https://api.github.com/users/mschoch/received_events","type":"User","site_admin":false},"body":"one thought here is that we have an unconditional for loop, but this else block is a case you check every loop iteration to bail on the loop.  so, wouldn't it be more clear to invert that (since it's an else case) and make that the condition of the for loop?\r\n\r\nthe only downside i see is that right now you always call notifyMergeWatchers regardless of this condition, you'd need it before the for loop, and again inside the loop (presumably now at the end of the loop).  but, even though that makes it feel longer, you can drop the else case, and the \"continue OUTER\" becomes unnecessary too as you'd want to proceed to notifyMergeWatchers again and let the loop naturally continue without need a continue","created_at":"2018-02-23T19:13:29Z","updated_at":"2018-02-23T19:13:50Z","html_url":"https://github.com/blevesearch/bleve/pull/777#discussion_r170340641","pull_request_url":"https://api.github.com/repos/blevesearch/bleve/pulls/777","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/blevesearch/bleve/pulls/comments/170340641"},"html":{"href":"https://github.com/blevesearch/bleve/pull/777#discussion_r170340641"},"pull_request":{"href":"https://api.github.com/repos/blevesearch/bleve/pulls/777"}}},"pull_request":{"url":"https://api.github.com/repos/blevesearch/bleve/pulls/777","id":169083076,"html_url":"https://github.com/blevesearch/bleve/pull/777","diff_url":"https://github.com/blevesearch/bleve/pull/777.diff","patch_url":"https://github.com/blevesearch/bleve/pull/777.patch","issue_url":"https://api.github.com/repos/blevesearch/bleve/issues/777","number":777,"state":"open","locked":false,"title":"pausing persister until merging catches up","user":{"login":"sreekanth-cb","id":25240115,"avatar_url":"https://avatars1.githubusercontent.com/u/25240115?v=4","gravatar_id":"","url":"https://api.github.com/users/sreekanth-cb","html_url":"https://github.com/sreekanth-cb","followers_url":"https://api.github.com/users/sreekanth-cb/followers","following_url":"https://api.github.com/users/sreekanth-cb/following{/other_user}","gists_url":"https://api.github.com/users/sreekanth-cb/gists{/gist_id}","starred_url":"https://api.github.com/users/sreekanth-cb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sreekanth-cb/subscriptions","organizations_url":"https://api.github.com/users/sreekanth-cb/orgs","repos_url":"https://api.github.com/users/sreekanth-cb/repos","events_url":"https://api.github.com/users/sreekanth-cb/events{/privacy}","received_events_url":"https://api.github.com/users/sreekanth-cb/received_events","type":"User","site_admin":false},"body":"adding a pause to persister until the merger catches up.","created_at":"2018-02-14T11:18:39Z","updated_at":"2018-02-23T19:13:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b0456f4fa97a93bc93528546b6b6c3834fd920b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/blevesearch/bleve/pulls/777/commits","review_comments_url":"https://api.github.com/repos/blevesearch/bleve/pulls/777/comments","review_comment_url":"https://api.github.com/repos/blevesearch/bleve/pulls/comments{/number}","comments_url":"https://api.github.com/repos/blevesearch/bleve/issues/777/comments","statuses_url":"https://api.github.com/repos/blevesearch/bleve/statuses/a8ebf2a553c21012733a24bc950d88fb2830f955","head":{"label":"sreekanth-cb:persister_pause","ref":"persister_pause","sha":"a8ebf2a553c21012733a24bc950d88fb2830f955","user":{"login":"sreekanth-cb","id":25240115,"avatar_url":"https://avatars1.githubusercontent.com/u/25240115?v=4","gravatar_id":"","url":"https://api.github.com/users/sreekanth-cb","html_url":"https://github.com/sreekanth-cb","followers_url":"https://api.github.com/users/sreekanth-cb/followers","following_url":"https://api.github.com/users/sreekanth-cb/following{/other_user}","gists_url":"https://api.github.com/users/sreekanth-cb/gists{/gist_id}","starred_url":"https://api.github.com/users/sreekanth-cb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sreekanth-cb/subscriptions","organizations_url":"https://api.github.com/users/sreekanth-cb/orgs","repos_url":"https://api.github.com/users/sreekanth-cb/repos","events_url":"https://api.github.com/users/sreekanth-cb/events{/privacy}","received_events_url":"https://api.github.com/users/sreekanth-cb/received_events","type":"User","site_admin":false},"repo":{"id":119959181,"name":"bleve","full_name":"sreekanth-cb/bleve","owner":{"login":"sreekanth-cb","id":25240115,"avatar_url":"https://avatars1.githubusercontent.com/u/25240115?v=4","gravatar_id":"","url":"https://api.github.com/users/sreekanth-cb","html_url":"https://github.com/sreekanth-cb","followers_url":"https://api.github.com/users/sreekanth-cb/followers","following_url":"https://api.github.com/users/sreekanth-cb/following{/other_user}","gists_url":"https://api.github.com/users/sreekanth-cb/gists{/gist_id}","starred_url":"https://api.github.com/users/sreekanth-cb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sreekanth-cb/subscriptions","organizations_url":"https://api.github.com/users/sreekanth-cb/orgs","repos_url":"https://api.github.com/users/sreekanth-cb/repos","events_url":"https://api.github.com/users/sreekanth-cb/events{/privacy}","received_events_url":"https://api.github.com/users/sreekanth-cb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sreekanth-cb/bleve","description":"A modern text indexing library for go","fork":true,"url":"https://api.github.com/repos/sreekanth-cb/bleve","forks_url":"https://api.github.com/repos/sreekanth-cb/bleve/forks","keys_url":"https://api.github.com/repos/sreekanth-cb/bleve/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sreekanth-cb/bleve/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sreekanth-cb/bleve/teams","hooks_url":"https://api.github.com/repos/sreekanth-cb/bleve/hooks","issue_events_url":"https://api.github.com/repos/sreekanth-cb/bleve/issues/events{/number}","events_url":"https://api.github.com/repos/sreekanth-cb/bleve/events","assignees_url":"https://api.github.com/repos/sreekanth-cb/bleve/assignees{/user}","branches_url":"https://api.github.com/repos/sreekanth-cb/bleve/branches{/branch}","tags_url":"https://api.github.com/repos/sreekanth-cb/bleve/tags","blobs_url":"https://api.github.com/repos/sreekanth-cb/bleve/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sreekanth-cb/bleve/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sreekanth-cb/bleve/git/refs{/sha}","trees_url":"https://api.github.com/repos/sreekanth-cb/bleve/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sreekanth-cb/bleve/statuses/{sha}","languages_url":"https://api.github.com/repos/sreekanth-cb/bleve/languages","stargazers_url":"https://api.github.com/repos/sreekanth-cb/bleve/stargazers","contributors_url":"https://api.github.com/repos/sreekanth-cb/bleve/contributors","subscribers_url":"https://api.github.com/repos/sreekanth-cb/bleve/subscribers","subscription_url":"https://api.github.com/repos/sreekanth-cb/bleve/subscription","commits_url":"https://api.github.com/repos/sreekanth-cb/bleve/commits{/sha}","git_commits_url":"https://api.github.com/repos/sreekanth-cb/bleve/git/commits{/sha}","comments_url":"https://api.github.com/repos/sreekanth-cb/bleve/comments{/number}","issue_comment_url":"https://api.github.com/repos/sreekanth-cb/bleve/issues/comments{/number}","contents_url":"https://api.github.com/repos/sreekanth-cb/bleve/contents/{+path}","compare_url":"https://api.github.com/repos/sreekanth-cb/bleve/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sreekanth-cb/bleve/merges","archive_url":"https://api.github.com/repos/sreekanth-cb/bleve/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sreekanth-cb/bleve/downloads","issues_url":"https://api.github.com/repos/sreekanth-cb/bleve/issues{/number}","pulls_url":"https://api.github.com/repos/sreekanth-cb/bleve/pulls{/number}","milestones_url":"https://api.github.com/repos/sreekanth-cb/bleve/milestones{/number}","notifications_url":"https://api.github.com/repos/sreekanth-cb/bleve/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sreekanth-cb/bleve/labels{/name}","releases_url":"https://api.github.com/repos/sreekanth-cb/bleve/releases{/id}","deployments_url":"https://api.github.com/repos/sreekanth-cb/bleve/deployments","created_at":"2018-02-02T09:09:36Z","updated_at":"2018-02-02T09:09:40Z","pushed_at":"2018-02-23T10:39:54Z","git_url":"git://github.com/sreekanth-cb/bleve.git","ssh_url":"git@github.com:sreekanth-cb/bleve.git","clone_url":"https://github.com/sreekanth-cb/bleve.git","svn_url":"https://github.com/sreekanth-cb/bleve","homepage":null,"size":11711,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"blevesearch:master","ref":"master","sha":"030469a35110568f7632632c83e281b5b30fbe92","user":{"login":"blevesearch","id":8562608,"avatar_url":"https://avatars2.githubusercontent.com/u/8562608?v=4","gravatar_id":"","url":"https://api.github.com/users/blevesearch","html_url":"https://github.com/blevesearch","followers_url":"https://api.github.com/users/blevesearch/followers","following_url":"https://api.github.com/users/blevesearch/following{/other_user}","gists_url":"https://api.github.com/users/blevesearch/gists{/gist_id}","starred_url":"https://api.github.com/users/blevesearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blevesearch/subscriptions","organizations_url":"https://api.github.com/users/blevesearch/orgs","repos_url":"https://api.github.com/users/blevesearch/repos","events_url":"https://api.github.com/users/blevesearch/events{/privacy}","received_events_url":"https://api.github.com/users/blevesearch/received_events","type":"Organization","site_admin":false},"repo":{"id":18893367,"name":"bleve","full_name":"blevesearch/bleve","owner":{"login":"blevesearch","id":8562608,"avatar_url":"https://avatars2.githubusercontent.com/u/8562608?v=4","gravatar_id":"","url":"https://api.github.com/users/blevesearch","html_url":"https://github.com/blevesearch","followers_url":"https://api.github.com/users/blevesearch/followers","following_url":"https://api.github.com/users/blevesearch/following{/other_user}","gists_url":"https://api.github.com/users/blevesearch/gists{/gist_id}","starred_url":"https://api.github.com/users/blevesearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blevesearch/subscriptions","organizations_url":"https://api.github.com/users/blevesearch/orgs","repos_url":"https://api.github.com/users/blevesearch/repos","events_url":"https://api.github.com/users/blevesearch/events{/privacy}","received_events_url":"https://api.github.com/users/blevesearch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/blevesearch/bleve","description":"A modern text indexing library for go","fork":false,"url":"https://api.github.com/repos/blevesearch/bleve","forks_url":"https://api.github.com/repos/blevesearch/bleve/forks","keys_url":"https://api.github.com/repos/blevesearch/bleve/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blevesearch/bleve/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blevesearch/bleve/teams","hooks_url":"https://api.github.com/repos/blevesearch/bleve/hooks","issue_events_url":"https://api.github.com/repos/blevesearch/bleve/issues/events{/number}","events_url":"https://api.github.com/repos/blevesearch/bleve/events","assignees_url":"https://api.github.com/repos/blevesearch/bleve/assignees{/user}","branches_url":"https://api.github.com/repos/blevesearch/bleve/branches{/branch}","tags_url":"https://api.github.com/repos/blevesearch/bleve/tags","blobs_url":"https://api.github.com/repos/blevesearch/bleve/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blevesearch/bleve/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blevesearch/bleve/git/refs{/sha}","trees_url":"https://api.github.com/repos/blevesearch/bleve/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blevesearch/bleve/statuses/{sha}","languages_url":"https://api.github.com/repos/blevesearch/bleve/languages","stargazers_url":"https://api.github.com/repos/blevesearch/bleve/stargazers","contributors_url":"https://api.github.com/repos/blevesearch/bleve/contributors","subscribers_url":"https://api.github.com/repos/blevesearch/bleve/subscribers","subscription_url":"https://api.github.com/repos/blevesearch/bleve/subscription","commits_url":"https://api.github.com/repos/blevesearch/bleve/commits{/sha}","git_commits_url":"https://api.github.com/repos/blevesearch/bleve/git/commits{/sha}","comments_url":"https://api.github.com/repos/blevesearch/bleve/comments{/number}","issue_comment_url":"https://api.github.com/repos/blevesearch/bleve/issues/comments{/number}","contents_url":"https://api.github.com/repos/blevesearch/bleve/contents/{+path}","compare_url":"https://api.github.com/repos/blevesearch/bleve/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blevesearch/bleve/merges","archive_url":"https://api.github.com/repos/blevesearch/bleve/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blevesearch/bleve/downloads","issues_url":"https://api.github.com/repos/blevesearch/bleve/issues{/number}","pulls_url":"https://api.github.com/repos/blevesearch/bleve/pulls{/number}","milestones_url":"https://api.github.com/repos/blevesearch/bleve/milestones{/number}","notifications_url":"https://api.github.com/repos/blevesearch/bleve/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blevesearch/bleve/labels{/name}","releases_url":"https://api.github.com/repos/blevesearch/bleve/releases{/id}","deployments_url":"https://api.github.com/repos/blevesearch/bleve/deployments","created_at":"2014-04-17T21:02:18Z","updated_at":"2018-02-23T18:27:02Z","pushed_at":"2018-02-23T17:17:25Z","git_url":"git://github.com/blevesearch/bleve.git","ssh_url":"git@github.com:blevesearch/bleve.git","clone_url":"https://github.com/blevesearch/bleve.git","svn_url":"https://github.com/blevesearch/bleve","homepage":null,"size":11707,"stargazers_count":4036,"watchers_count":4036,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":337,"mirror_url":null,"archived":false,"open_issues_count":112,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":337,"open_issues":112,"watchers":4036,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/blevesearch/bleve/pulls/777"},"html":{"href":"https://github.com/blevesearch/bleve/pull/777"},"issue":{"href":"https://api.github.com/repos/blevesearch/bleve/issues/777"},"comments":{"href":"https://api.github.com/repos/blevesearch/bleve/issues/777/comments"},"review_comments":{"href":"https://api.github.com/repos/blevesearch/bleve/pulls/777/comments"},"review_comment":{"href":"https://api.github.com/repos/blevesearch/bleve/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/blevesearch/bleve/pulls/777/commits"},"statuses":{"href":"https://api.github.com/repos/blevesearch/bleve/statuses/a8ebf2a553c21012733a24bc950d88fb2830f955"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mschoch"}}