-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compactor: Add Revisional compactor #8123
Conversation
5f22d13
to
e65d407
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general approach looks OK; some minor nits. It'd be nice to consolidate duplicated the revisional/periodic code, but I don't see an obvious way to do it at the moment
etcdmain/config.go
Outdated
@@ -199,7 +199,8 @@ func newConfig() *config { | |||
// version | |||
fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.") | |||
|
|||
fs.IntVar(&cfg.AutoCompactionRetention, "auto-compaction-retention", 0, "Auto compaction retention for mvcc key value store in hour. 0 means disable auto compaction.") | |||
fs.IntVar(&cfg.AutoCompactionRetention, "auto-compaction-retention", 0, "Auto compaction retention for mvcc key value store. 0 means disable auto compaction.") | |||
fs.IntVar(&cfg.AutoCompactionMode, "auto-compaction-mode", 0, "Interpreted 'auto-comapction-retention' as hours when 0, as revision numbers when 1.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a string taking some nice name for the policy, something like "hourly" (default) and "revision"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we might want to change the frequency of compaction by the periodic compactor, I think 'period' would be better here. If we use 'hourly', we cannot change the interval.
(To keep the storage size more consistent, it might be better for the periodic compactor to run compaction more often).
@@ -469,8 +469,15 @@ func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) { | |||
return nil, err | |||
} | |||
srv.authStore = auth.NewAuthStore(srv.be, tp) | |||
if h := cfg.AutoCompactionRetention; h != 0 { | |||
srv.compactor = compactor.NewPeriodic(h, srv.kv, srv) | |||
if num := cfg.AutoCompactionRetention; num != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly have
srv.compactor = compactor.New(cfg.AutoCompactionMode, cfg.AutoCompactionRetention, srv.kv, srv)
so that the builder logic is kept with the compactor package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Let me know if you'd like to define a type for the mode like type CompactionMode string
.
e65d407
to
3b780e5
Compare
To keep backward compatibility, I didn't change the type of retention hours from |
compactor/revisional.go
Outdated
continue | ||
} | ||
|
||
plog.Noticef("Starting auto-compaction at revision %d", rev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print out our retention here?
compactor/revisional.go
Outdated
paused bool | ||
} | ||
|
||
func NewRevisional(retention int64, rg RevGetter, c Compactable) *Revisional { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document this please
compactor/periodic.go
Outdated
paused bool | ||
} | ||
|
||
func NewPeriodic(h int, rg RevGetter, c Compactable) *Periodic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comments?
3b780e5
to
5d72e95
Compare
Done adding comments. |
5d72e95
to
8b5f70b
Compare
compactor/periodic.go
Outdated
@@ -0,0 +1,122 @@ | |||
// Copyright 2016 The etcd Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to 2017.
8b5f70b
to
057dc9f
Compare
compactor/compactor.go
Outdated
@@ -32,8 +31,24 @@ var ( | |||
const ( | |||
checkCompactionInterval = 5 * time.Minute | |||
executeCompactionInterval = time.Hour | |||
|
|||
ModePeriodic = "period" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
periodic
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
Should I rename the Revisional
to Revision
and ModeRevisonal = "revision"
to ModeRevison = "revision"
? mixing "revisional" and "revision" could be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, changed to Revision
for consistency.
etcdmain/config.go
Outdated
@@ -199,7 +199,8 @@ func newConfig() *config { | |||
// version | |||
fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.") | |||
|
|||
fs.IntVar(&cfg.AutoCompactionRetention, "auto-compaction-retention", 0, "Auto compaction retention for mvcc key value store in hour. 0 means disable auto compaction.") | |||
fs.IntVar(&cfg.AutoCompactionRetention, "auto-compaction-retention", 0, "Auto compaction retention for mvcc key value store. 0 means disable auto compaction.") | |||
fs.StringVar(&cfg.AutoCompactionMode, "auto-compaction-mode", "period", "Interpreted 'auto-comapction-retention' as hours when 'period', as revision numbers when 'revision'.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interpret 'auto-compaction-retention'
...
lgtm after renaming the mode from |
057dc9f
to
e4192f8
Compare
Renamed and squashed! |
embed/config.go
Outdated
@@ -80,6 +80,7 @@ type Config struct { | |||
Name string `json:"name"` | |||
SnapCount uint64 `json:"snapshot-count"` | |||
AutoCompactionRetention int `json:"auto-compaction-retention"` | |||
AutoCompactionMode string `json:"auto-compaction-mode` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing end quote is causing CI to fail
please change the commit message's first line to |
e4192f8
to
e38eb4c
Compare
@yudai still failing CI on |
e38eb4c
to
a3f8f47
Compare
@heyitsanthony Oops, sorry about that. Now it should be fixed |
CI failures are unrelated. merging. thanks! @yudai |
Hello,
For #8098, adding a new compactor named
Revisional
, which runs compaction every 5 minutes.To switch the compactor from the default
Periodic
, I added a new option--auto-compaction-mode
as well.Some Notes:
Periodic
run compaction every 5 minutes as well for consistency? (currently it runs hourly)periodic
andrevisional
.