{"action":"created","comment":{"url":"https://api.github.com/repos/sorintlab/stolon/pulls/comments/167165171","pull_request_review_id":95343328,"id":167165171,"diff_hunk":"@@ -842,6 +842,80 @@ func (p *PostgresKeeper) updateReplSlots(dbLocalState *DBLocalState, followersUI\n \treturn nil\n }\n \n+func (p *PostgresKeeper) recreateAddonReplicationSlots(addonSlotNames []string) error {\n+\tvar existingReplicationSlots []string\n+\texistingReplicationSlots, err := p.pgm.GetReplicationSlots()\n+\n+\tif err != nil {\n+\t\tlog.Errorw(\"failed to get replication slots\", zap.Error(err))\n+\t\treturn err\n+\t}\n+\n+\t// detect not stolon replication slots\n+\tnotStolonSlots := []string{}\n+\tfor _, currReplicationSlotName := range existingReplicationSlots {\n+\t\tif !common.IsStolonName(currReplicationSlotName) {\n+\t\t\tnotStolonSlots = append(notStolonSlots, currReplicationSlotName)\n+\t\t}\n+\t}\n+\n+\t// detect slot that should be dropped\n+\tslotsToDrop := []string{}\n+\n+\tfor _, removeCandidateSlot := range notStolonSlots {\n+\t\tslotShouldSurvive := false\n+\t\tfor _, replSlotName := range addonSlotNames {\n+\t\t\tif replSlotName == removeCandidateSlot {\n+\t\t\t\tslotShouldSurvive = true\n+\t\t\t}\n+\t\t}\n+\n+\t\tif !slotShouldSurvive { // slot not detected as additional, so schedule the removal\n+\t\t\tslotsToDrop = append(slotsToDrop, removeCandidateSlot)\n+\t\t}\n+\t}\n+\n+\t// detect slots that should be created\n+\tslotsToCreate := []string{}\n+\n+\tfor _, addReplicationSlotName := range addonSlotNames {\n+\t\tslotExists := false\n+\n+\t\tfor _, currReplicationSlotName := range notStolonSlots {\n+\t\t\tif addReplicationSlotName == currReplicationSlotName {\n+\t\t\t\tslotExists = true\n+\t\t\t\tbreak\n+\t\t\t}\n+\t\t}\n+\t\tif !slotExists {\n+\t\t\tslotsToCreate = append(slotsToCreate, strings.TrimSpace(addReplicationSlotName))\n+\t\t}\n+\t}\n+\n+\t// drop unnecessary slots\n+\tif len(slotsToDrop) > 0 {\n+\t\tfor _, dropSlotName := range slotsToDrop {\n+\t\t\tlog.Infow(\"Drop slot\", \"dropSlotName\", dropSlotName)\n+\t\t\tif err = p.pgm.DropReplicationSlot(dropSlotName); err != nil {\n+\t\t\t\tlog.Errorw(\"Failed to drop replication slot\", \"slotName\", dropSlotName, zap.Error(err))\n+\t\t\t\treturn err\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t// create required slots\n+\tif len(slotsToCreate) > 0 {","path":"cmd/keeper/keeper.go","position":66,"original_position":66,"commit_id":"f436c6ca248dbc47257ca235caa91b7e543accc0","original_commit_id":"f436c6ca248dbc47257ca235caa91b7e543accc0","user":{"login":"sgotti","id":1690273,"avatar_url":"https://avatars2.githubusercontent.com/u/1690273?v=4","gravatar_id":"","url":"https://api.github.com/users/sgotti","html_url":"https://github.com/sgotti","followers_url":"https://api.github.com/users/sgotti/followers","following_url":"https://api.github.com/users/sgotti/following{/other_user}","gists_url":"https://api.github.com/users/sgotti/gists{/gist_id}","starred_url":"https://api.github.com/users/sgotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgotti/subscriptions","organizations_url":"https://api.github.com/users/sgotti/orgs","repos_url":"https://api.github.com/users/sgotti/repos","events_url":"https://api.github.com/users/sgotti/events{/privacy}","received_events_url":"https://api.github.com/users/sgotti/received_events","type":"User","site_admin":false},"body":"no need to check the length > 0. The range will just take care of it.","created_at":"2018-02-09T08:30:57Z","updated_at":"2018-02-09T08:58:47Z","html_url":"https://github.com/sorintlab/stolon/pull/434#discussion_r167165171","pull_request_url":"https://api.github.com/repos/sorintlab/stolon/pulls/434","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sorintlab/stolon/pulls/comments/167165171"},"html":{"href":"https://github.com/sorintlab/stolon/pull/434#discussion_r167165171"},"pull_request":{"href":"https://api.github.com/repos/sorintlab/stolon/pulls/434"}}},"pull_request":{"url":"https://api.github.com/repos/sorintlab/stolon/pulls/434","id":168094005,"html_url":"https://github.com/sorintlab/stolon/pull/434","diff_url":"https://github.com/sorintlab/stolon/pull/434.diff","patch_url":"https://github.com/sorintlab/stolon/pull/434.patch","issue_url":"https://api.github.com/repos/sorintlab/stolon/issues/434","number":434,"state":"open","locked":false,"title":"Additional replication slots","user":{"login":"saranhada","id":35447626,"avatar_url":"https://avatars0.githubusercontent.com/u/35447626?v=4","gravatar_id":"","url":"https://api.github.com/users/saranhada","html_url":"https://github.com/saranhada","followers_url":"https://api.github.com/users/saranhada/followers","following_url":"https://api.github.com/users/saranhada/following{/other_user}","gists_url":"https://api.github.com/users/saranhada/gists{/gist_id}","starred_url":"https://api.github.com/users/saranhada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saranhada/subscriptions","organizations_url":"https://api.github.com/users/saranhada/orgs","repos_url":"https://api.github.com/users/saranhada/repos","events_url":"https://api.github.com/users/saranhada/events{/privacy}","received_events_url":"https://api.github.com/users/saranhada/received_events","type":"User","site_admin":false},"body":"@sgotti please review the pull request. If it is ok then let me create auto tests. This PR is the continuance  of PR #410 started from the scratch","created_at":"2018-02-08T21:38:24Z","updated_at":"2018-02-09T08:58:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e955b67eb7ae186d28fdbead503088180cc5c54","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/sorintlab/stolon/pulls/434/commits","review_comments_url":"https://api.github.com/repos/sorintlab/stolon/pulls/434/comments","review_comment_url":"https://api.github.com/repos/sorintlab/stolon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sorintlab/stolon/issues/434/comments","statuses_url":"https://api.github.com/repos/sorintlab/stolon/statuses/f436c6ca248dbc47257ca235caa91b7e543accc0","head":{"label":"saranhada:ADD_REPLICATION_SLOTS","ref":"ADD_REPLICATION_SLOTS","sha":"f436c6ca248dbc47257ca235caa91b7e543accc0","user":{"login":"saranhada","id":35447626,"avatar_url":"https://avatars0.githubusercontent.com/u/35447626?v=4","gravatar_id":"","url":"https://api.github.com/users/saranhada","html_url":"https://github.com/saranhada","followers_url":"https://api.github.com/users/saranhada/followers","following_url":"https://api.github.com/users/saranhada/following{/other_user}","gists_url":"https://api.github.com/users/saranhada/gists{/gist_id}","starred_url":"https://api.github.com/users/saranhada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saranhada/subscriptions","organizations_url":"https://api.github.com/users/saranhada/orgs","repos_url":"https://api.github.com/users/saranhada/repos","events_url":"https://api.github.com/users/saranhada/events{/privacy}","received_events_url":"https://api.github.com/users/saranhada/received_events","type":"User","site_admin":false},"repo":{"id":117515866,"name":"stolon","full_name":"saranhada/stolon","owner":{"login":"saranhada","id":35447626,"avatar_url":"https://avatars0.githubusercontent.com/u/35447626?v=4","gravatar_id":"","url":"https://api.github.com/users/saranhada","html_url":"https://github.com/saranhada","followers_url":"https://api.github.com/users/saranhada/followers","following_url":"https://api.github.com/users/saranhada/following{/other_user}","gists_url":"https://api.github.com/users/saranhada/gists{/gist_id}","starred_url":"https://api.github.com/users/saranhada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saranhada/subscriptions","organizations_url":"https://api.github.com/users/saranhada/orgs","repos_url":"https://api.github.com/users/saranhada/repos","events_url":"https://api.github.com/users/saranhada/events{/privacy}","received_events_url":"https://api.github.com/users/saranhada/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/saranhada/stolon","description":"PostgreSQL cloud native High Availability and more.","fork":true,"url":"https://api.github.com/repos/saranhada/stolon","forks_url":"https://api.github.com/repos/saranhada/stolon/forks","keys_url":"https://api.github.com/repos/saranhada/stolon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saranhada/stolon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saranhada/stolon/teams","hooks_url":"https://api.github.com/repos/saranhada/stolon/hooks","issue_events_url":"https://api.github.com/repos/saranhada/stolon/issues/events{/number}","events_url":"https://api.github.com/repos/saranhada/stolon/events","assignees_url":"https://api.github.com/repos/saranhada/stolon/assignees{/user}","branches_url":"https://api.github.com/repos/saranhada/stolon/branches{/branch}","tags_url":"https://api.github.com/repos/saranhada/stolon/tags","blobs_url":"https://api.github.com/repos/saranhada/stolon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saranhada/stolon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saranhada/stolon/git/refs{/sha}","trees_url":"https://api.github.com/repos/saranhada/stolon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saranhada/stolon/statuses/{sha}","languages_url":"https://api.github.com/repos/saranhada/stolon/languages","stargazers_url":"https://api.github.com/repos/saranhada/stolon/stargazers","contributors_url":"https://api.github.com/repos/saranhada/stolon/contributors","subscribers_url":"https://api.github.com/repos/saranhada/stolon/subscribers","subscription_url":"https://api.github.com/repos/saranhada/stolon/subscription","commits_url":"https://api.github.com/repos/saranhada/stolon/commits{/sha}","git_commits_url":"https://api.github.com/repos/saranhada/stolon/git/commits{/sha}","comments_url":"https://api.github.com/repos/saranhada/stolon/comments{/number}","issue_comment_url":"https://api.github.com/repos/saranhada/stolon/issues/comments{/number}","contents_url":"https://api.github.com/repos/saranhada/stolon/contents/{+path}","compare_url":"https://api.github.com/repos/saranhada/stolon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saranhada/stolon/merges","archive_url":"https://api.github.com/repos/saranhada/stolon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saranhada/stolon/downloads","issues_url":"https://api.github.com/repos/saranhada/stolon/issues{/number}","pulls_url":"https://api.github.com/repos/saranhada/stolon/pulls{/number}","milestones_url":"https://api.github.com/repos/saranhada/stolon/milestones{/number}","notifications_url":"https://api.github.com/repos/saranhada/stolon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saranhada/stolon/labels{/name}","releases_url":"https://api.github.com/repos/saranhada/stolon/releases{/id}","deployments_url":"https://api.github.com/repos/saranhada/stolon/deployments","created_at":"2018-01-15T08:07:36Z","updated_at":"2018-01-15T08:07:38Z","pushed_at":"2018-02-08T21:37:57Z","git_url":"git://github.com/saranhada/stolon.git","ssh_url":"git@github.com:saranhada/stolon.git","clone_url":"https://github.com/saranhada/stolon.git","svn_url":"https://github.com/saranhada/stolon","homepage":"","size":5151,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sorintlab:master","ref":"master","sha":"bacae4ca24a21b700df04067b5274640326a1d56","user":{"login":"sorintlab","id":13370318,"avatar_url":"https://avatars1.githubusercontent.com/u/13370318?v=4","gravatar_id":"","url":"https://api.github.com/users/sorintlab","html_url":"https://github.com/sorintlab","followers_url":"https://api.github.com/users/sorintlab/followers","following_url":"https://api.github.com/users/sorintlab/following{/other_user}","gists_url":"https://api.github.com/users/sorintlab/gists{/gist_id}","starred_url":"https://api.github.com/users/sorintlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorintlab/subscriptions","organizations_url":"https://api.github.com/users/sorintlab/orgs","repos_url":"https://api.github.com/users/sorintlab/repos","events_url":"https://api.github.com/users/sorintlab/events{/privacy}","received_events_url":"https://api.github.com/users/sorintlab/received_events","type":"Organization","site_admin":false},"repo":{"id":43884372,"name":"stolon","full_name":"sorintlab/stolon","owner":{"login":"sorintlab","id":13370318,"avatar_url":"https://avatars1.githubusercontent.com/u/13370318?v=4","gravatar_id":"","url":"https://api.github.com/users/sorintlab","html_url":"https://github.com/sorintlab","followers_url":"https://api.github.com/users/sorintlab/followers","following_url":"https://api.github.com/users/sorintlab/following{/other_user}","gists_url":"https://api.github.com/users/sorintlab/gists{/gist_id}","starred_url":"https://api.github.com/users/sorintlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorintlab/subscriptions","organizations_url":"https://api.github.com/users/sorintlab/orgs","repos_url":"https://api.github.com/users/sorintlab/repos","events_url":"https://api.github.com/users/sorintlab/events{/privacy}","received_events_url":"https://api.github.com/users/sorintlab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sorintlab/stolon","description":"PostgreSQL cloud native High Availability and more.","fork":false,"url":"https://api.github.com/repos/sorintlab/stolon","forks_url":"https://api.github.com/repos/sorintlab/stolon/forks","keys_url":"https://api.github.com/repos/sorintlab/stolon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sorintlab/stolon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sorintlab/stolon/teams","hooks_url":"https://api.github.com/repos/sorintlab/stolon/hooks","issue_events_url":"https://api.github.com/repos/sorintlab/stolon/issues/events{/number}","events_url":"https://api.github.com/repos/sorintlab/stolon/events","assignees_url":"https://api.github.com/repos/sorintlab/stolon/assignees{/user}","branches_url":"https://api.github.com/repos/sorintlab/stolon/branches{/branch}","tags_url":"https://api.github.com/repos/sorintlab/stolon/tags","blobs_url":"https://api.github.com/repos/sorintlab/stolon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sorintlab/stolon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sorintlab/stolon/git/refs{/sha}","trees_url":"https://api.github.com/repos/sorintlab/stolon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sorintlab/stolon/statuses/{sha}","languages_url":"https://api.github.com/repos/sorintlab/stolon/languages","stargazers_url":"https://api.github.com/repos/sorintlab/stolon/stargazers","contributors_url":"https://api.github.com/repos/sorintlab/stolon/contributors","subscribers_url":"https://api.github.com/repos/sorintlab/stolon/subscribers","subscription_url":"https://api.github.com/repos/sorintlab/stolon/subscription","commits_url":"https://api.github.com/repos/sorintlab/stolon/commits{/sha}","git_commits_url":"https://api.github.com/repos/sorintlab/stolon/git/commits{/sha}","comments_url":"https://api.github.com/repos/sorintlab/stolon/comments{/number}","issue_comment_url":"https://api.github.com/repos/sorintlab/stolon/issues/comments{/number}","contents_url":"https://api.github.com/repos/sorintlab/stolon/contents/{+path}","compare_url":"https://api.github.com/repos/sorintlab/stolon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sorintlab/stolon/merges","archive_url":"https://api.github.com/repos/sorintlab/stolon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sorintlab/stolon/downloads","issues_url":"https://api.github.com/repos/sorintlab/stolon/issues{/number}","pulls_url":"https://api.github.com/repos/sorintlab/stolon/pulls{/number}","milestones_url":"https://api.github.com/repos/sorintlab/stolon/milestones{/number}","notifications_url":"https://api.github.com/repos/sorintlab/stolon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sorintlab/stolon/labels{/name}","releases_url":"https://api.github.com/repos/sorintlab/stolon/releases{/id}","deployments_url":"https://api.github.com/repos/sorintlab/stolon/deployments","created_at":"2015-10-08T11:38:27Z","updated_at":"2018-02-08T19:20:38Z","pushed_at":"2018-02-08T21:38:24Z","git_url":"git://github.com/sorintlab/stolon.git","ssh_url":"git@github.com:sorintlab/stolon.git","clone_url":"https://github.com/sorintlab/stolon.git","svn_url":"https://github.com/sorintlab/stolon","homepage":"","size":5109,"stargazers_count":1206,"watchers_count":1206,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":97,"mirror_url":null,"archived":false,"open_issues_count":46,"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":97,"open_issues":46,"watchers":1206,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sorintlab/stolon/pulls/434"},"html":{"href":"https://github.com/sorintlab/stolon/pull/434"},"issue":{"href":"https://api.github.com/repos/sorintlab/stolon/issues/434"},"comments":{"href":"https://api.github.com/repos/sorintlab/stolon/issues/434/comments"},"review_comments":{"href":"https://api.github.com/repos/sorintlab/stolon/pulls/434/comments"},"review_comment":{"href":"https://api.github.com/repos/sorintlab/stolon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sorintlab/stolon/pulls/434/commits"},"statuses":{"href":"https://api.github.com/repos/sorintlab/stolon/statuses/f436c6ca248dbc47257ca235caa91b7e543accc0"}},"author_association":"NONE"}}
{"actor":{"display_login":"sgotti"}}