{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/176876196","pull_request_review_id":106663027,"id":176876196,"diff_hunk":"@@ -83,30 +122,55 @@ func (t *Periodic) Run() {\n \t\t\t\t}\n \t\t\t}\n \n-\t\t\t// wait up to initial given period\n-\t\t\tif t.clock.Now().Sub(initialWait) < t.period {\n+\t\t\tif t.clock.Now().Sub(lastSuccess) < baseInterval {\n \t\t\t\tcontinue\n \t\t\t}\n \n-\t\t\trev, remaining := t.getRev()\n-\t\t\tif rev < 0 {\n-\t\t\t\tcontinue\n+\t\t\t// wait up to initial given period\n+\t\t\tif baseInterval == t.period {\n+\t\t\t\tbaseInterval = compactInterval\n \t\t\t}\n+\t\t\trev := t.revs[0]\n \n \t\t\tplog.Noticef(\"Starting auto-compaction at revision %d (retention: %v)\", rev, t.period)\n \t\t\t_, err := t.c.Compact(t.ctx, &pb.CompactionRequest{Revision: rev})\n \t\t\tif err == nil || err == mvcc.ErrCompacted {\n-\t\t\t\t// move to next sliding window\n-\t\t\t\tt.revs = remaining\n+\t\t\t\tlastSuccess = t.clock.Now()\n \t\t\t\tplog.Noticef(\"Finished auto-compaction at revision %d\", rev)\n \t\t\t} else {\n \t\t\t\tplog.Noticef(\"Failed auto-compaction at revision %d (%v)\", rev, err)\n-\t\t\t\tplog.Noticef(\"Retry after %v\", interval)\n+\t\t\t\tplog.Noticef(\"Retry after %v\", retryInterval)\n \t\t\t}\n \t\t}\n \t}()\n }\n \n+// if given compaction period x is <1-hour, compact every x duration.\n+// (e.g. --auto-compaction-mode 'periodic' --auto-compaction-retention='10m', then compact every 10-minute)\n+// if given compaction period x is >1-hour, compact every hour.\n+// (e.g. --auto-compaction-mode 'periodic' --auto-compaction-retention='2h', then compact every 1-hour)\n+func (t *Periodic) getCompactInterval() time.Duration {\n+\titv := t.period\n+\tif itv > time.Hour {\n+\t\titv = time.Hour\n+\t}\n+\treturn itv\n+}\n+\n+func (t *Periodic) getRetentions() int {\n+\treturn int(t.period / t.getRetryInterval())","path":"compactor/periodic.go","position":113,"original_position":113,"commit_id":"377cf6b788cf1fdc488b3a55500cdc9b70fffcf6","original_commit_id":"377cf6b788cf1fdc488b3a55500cdc9b70fffcf6","user":{"login":"fanminshi","id":4983345,"avatar_url":"https://avatars3.githubusercontent.com/u/4983345?v=4","gravatar_id":"","url":"https://api.github.com/users/fanminshi","html_url":"https://github.com/fanminshi","followers_url":"https://api.github.com/users/fanminshi/followers","following_url":"https://api.github.com/users/fanminshi/following{/other_user}","gists_url":"https://api.github.com/users/fanminshi/gists{/gist_id}","starred_url":"https://api.github.com/users/fanminshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fanminshi/subscriptions","organizations_url":"https://api.github.com/users/fanminshi/orgs","repos_url":"https://api.github.com/users/fanminshi/repos","events_url":"https://api.github.com/users/fanminshi/events{/privacy}","received_events_url":"https://api.github.com/users/fanminshi/received_events","type":"User","site_admin":false},"body":"shouldn't this be `int(t.period / t.getRetryInterval()) + 1`?","created_at":"2018-03-23T22:11:33Z","updated_at":"2018-03-23T22:11:52Z","html_url":"https://github.com/coreos/etcd/pull/9485#discussion_r176876196","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/9485","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/176876196"},"html":{"href":"https://github.com/coreos/etcd/pull/9485#discussion_r176876196"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/9485"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/9485","id":177153219,"html_url":"https://github.com/coreos/etcd/pull/9485","diff_url":"https://github.com/coreos/etcd/pull/9485.diff","patch_url":"https://github.com/coreos/etcd/pull/9485.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/9485","number":9485,"state":"open","locked":false,"title":"compactor: adjust interval for period <1-hour","user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars0.githubusercontent.com/u/6799218?v=4","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"body":"Simplified version of https://github.com/coreos/etcd/pull/9482.\r\nSimilar to how v3.2 works while handling compaction period <1-hour.\r\n\r\nAddress https://github.com/coreos/etcd/pull/9443.","created_at":"2018-03-23T18:37:15Z","updated_at":"2018-03-23T22:11:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d694a1e9699e5b18cb217cdca66ef13fa579a10c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":258824920,"url":"https://api.github.com/repos/coreos/etcd/labels/Release-Backport/v3.3","name":"Release-Backport/v3.3","color":"40C4FF","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/9485/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/9485/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/9485/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/377cf6b788cf1fdc488b3a55500cdc9b70fffcf6","head":{"label":"gyuho:compactor","ref":"compactor","sha":"377cf6b788cf1fdc488b3a55500cdc9b70fffcf6","user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars0.githubusercontent.com/u/6799218?v=4","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"repo":{"id":42982042,"name":"etcd","full_name":"gyuho/etcd","owner":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars0.githubusercontent.com/u/6799218?v=4","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gyuho/etcd","description":"A distributed consistent key-value store for shared configuration and service discovery","fork":true,"url":"https://api.github.com/repos/gyuho/etcd","forks_url":"https://api.github.com/repos/gyuho/etcd/forks","keys_url":"https://api.github.com/repos/gyuho/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gyuho/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gyuho/etcd/teams","hooks_url":"https://api.github.com/repos/gyuho/etcd/hooks","issue_events_url":"https://api.github.com/repos/gyuho/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/gyuho/etcd/events","assignees_url":"https://api.github.com/repos/gyuho/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/gyuho/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/gyuho/etcd/tags","blobs_url":"https://api.github.com/repos/gyuho/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gyuho/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gyuho/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/gyuho/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gyuho/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/gyuho/etcd/languages","stargazers_url":"https://api.github.com/repos/gyuho/etcd/stargazers","contributors_url":"https://api.github.com/repos/gyuho/etcd/contributors","subscribers_url":"https://api.github.com/repos/gyuho/etcd/subscribers","subscription_url":"https://api.github.com/repos/gyuho/etcd/subscription","commits_url":"https://api.github.com/repos/gyuho/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/gyuho/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/gyuho/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/gyuho/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/gyuho/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/gyuho/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gyuho/etcd/merges","archive_url":"https://api.github.com/repos/gyuho/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gyuho/etcd/downloads","issues_url":"https://api.github.com/repos/gyuho/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/gyuho/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/gyuho/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/gyuho/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gyuho/etcd/labels{/name}","releases_url":"https://api.github.com/repos/gyuho/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/gyuho/etcd/deployments","created_at":"2015-09-23T06:15:42Z","updated_at":"2018-03-23T10:30:58Z","pushed_at":"2018-03-23T21:50:55Z","git_url":"git://github.com/gyuho/etcd.git","ssh_url":"git@github.com:gyuho/etcd.git","clone_url":"https://github.com/gyuho/etcd.git","svn_url":"https://github.com/gyuho/etcd","homepage":"","size":35800,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":false,"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":"coreos:master","ref":"master","sha":"f6f43ee7994b62c3310492d6fc0a65a02f3e835f","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars3.githubusercontent.com/u/3730757?v=4","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":11225014,"name":"etcd","full_name":"coreos/etcd","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars3.githubusercontent.com/u/3730757?v=4","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd","description":"Distributed reliable key-value store for the most critical data of a distributed system","fork":false,"url":"https://api.github.com/repos/coreos/etcd","forks_url":"https://api.github.com/repos/coreos/etcd/forks","keys_url":"https://api.github.com/repos/coreos/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd/teams","hooks_url":"https://api.github.com/repos/coreos/etcd/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd/events","assignees_url":"https://api.github.com/repos/coreos/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd/tags","blobs_url":"https://api.github.com/repos/coreos/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd/subscription","commits_url":"https://api.github.com/repos/coreos/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd/merges","archive_url":"https://api.github.com/repos/coreos/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd/downloads","issues_url":"https://api.github.com/repos/coreos/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd/deployments","created_at":"2013-07-06T21:57:21Z","updated_at":"2018-03-23T18:04:27Z","pushed_at":"2018-03-23T21:50:58Z","git_url":"git://github.com/coreos/etcd.git","ssh_url":"git@github.com:coreos/etcd.git","clone_url":"https://github.com/coreos/etcd.git","svn_url":"https://github.com/coreos/etcd","homepage":"https://coreos.com/etcd/docs/latest/","size":36869,"stargazers_count":17431,"watchers_count":17431,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3439,"mirror_url":null,"archived":false,"open_issues_count":256,"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":3439,"open_issues":256,"watchers":17431,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/9485"},"html":{"href":"https://github.com/coreos/etcd/pull/9485"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/9485"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/9485/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/9485/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/9485/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/377cf6b788cf1fdc488b3a55500cdc9b70fffcf6"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"fanminshi"}}