Skip to content
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

Make default retention policy configurable #2676

Closed
sklevenz opened this issue May 28, 2015 · 24 comments
Closed

Make default retention policy configurable #2676

sklevenz opened this issue May 28, 2015 · 24 comments
Labels
area/configuration difficulty/medium Resolving this issue should take up to a week
Milestone

Comments

@sklevenz
Copy link

For example:

Introduce two variables in config.toml file

"DefaultRetentionPolicy": "7d",
"DefaultShardDuration": "1d",

to make default retention configurable.

@yujinqiu
Copy link

+1

@beckettsean beckettsean added this to the 0.9.1 milestone May 28, 2015
@mnuessler
Copy link
Contributor

+1

@toddboom toddboom modified the milestones: 0.9.1, 0.9.2 Jun 5, 2015
@talbright
Copy link

I'm taking a crack at this, getting pretty close...

talbright added a commit to talbright/influxdb that referenced this issue Jun 7, 2015
retention-policy = "168h"
shard-duration = "24h"

Fixes influxdata#2676
@beckettsean beckettsean modified the milestones: 0.9.3, 0.9.2 Jul 15, 2015
@beckettsean beckettsean modified the milestones: 0.9.4, 0.9.3 Aug 6, 2015
@jeanpralo
Copy link

👍

@otoolep
Copy link
Contributor

otoolep commented Sep 23, 2015

The reason we've held off on this is that what if the user subsequently alters the default retention policy? Should the system always override on restart? We can make it so that the config settings only apply when the retention policy is created.

@jeanpralo
Copy link

Just my thought but I would rather have the default retention policy applied at the creation of a database, and if someone wants to alter it they can do it manually.

@otoolep otoolep added status/help-wanted difficulty/medium Resolving this issue should take up to a week labels Nov 4, 2015
@otoolep
Copy link
Contributor

otoolep commented Nov 4, 2015

This would definitely be a useful feature. The steps to implement this are as follows:

@otoolep otoolep closed this as completed Nov 4, 2015
@otoolep otoolep reopened this Nov 4, 2015
@pires
Copy link
Contributor

pires commented Nov 10, 2015

+1 for applying default policy only on database creation. On it!

@pires
Copy link
Contributor

pires commented Nov 10, 2015

@otoolep what would be the desired defaults?

@pires
Copy link
Contributor

pires commented Nov 10, 2015

Actually, @otoolep I was looking at #2805 and read the following by @pauldix:

Stuff in the toml config file should be host specific only. Retention policies are actually set at a cluster level. They're meta data that exist in the cluster metastore (regardless if you're running only a single server), so it doesn't really make sense to have this in the toml file.

Does it still applies? If so, this issue should be closed. Otherwise, #2805 should be reviewed once more because it seems to deliver. I would just add a couple tests where we guarantee a couple things:

  • defaults are enforced on database creation
  • values configured by the user are properly enforced on database creation

@otoolep
Copy link
Contributor

otoolep commented Nov 11, 2015

I can check with @pauldix but I think this is actually OK. We've done some similar things recently, and the key thing to understand is that the retention policy duration only applies on creation. If you look at the code, the duration is set to something, and right now it's set to infinity (0).

This change would be easy enough -- one simply defines the key, and if it's not set, one goes what the code does now. The PR you referenced is pretty close, except the default time is wrong.

I need to check with @pauldix to see if I can get him to agree if this change is actually OK. In practise I can see why users like the default retention policy, but don't like that it's always of infinite retention.

@pires
Copy link
Contributor

pires commented Nov 11, 2015

Sure. Keep us posted.

@pauldix
Copy link
Member

pauldix commented Nov 11, 2015

What's the desired result of this setting? That every time you create a database it has a given retention duration?

I think the more appropriate thing to do is to add something to the CREATE DATABASE command that lets you specify what the default duration would be. I think that would be super useful.

@pires
Copy link
Contributor

pires commented Nov 11, 2015

@pauldix something like CREATE DATABASE WITH RETENTION=24h NOAA_water_database?

@otoolep
Copy link
Contributor

otoolep commented Nov 11, 2015

I was wondering if should really be the full command, including name etc. But that could be over the top.

CREATE DATABASE NOAA_water_database WITH RETENTION 24h

might be more in line with our current standards -- the optional keywords come after the mandatory keywords, and we don't use = in the commands.

@pires
Copy link
Contributor

pires commented Nov 11, 2015

@otoolep can you please lead the way spec'ing this and I'll give it a try?

@otoolep
Copy link
Contributor

otoolep commented Nov 11, 2015

Sure.

The first step would be understanding how to add a command to our parser. It's not that difficult actually, if you can follow an example. For example this PR shows how the DROP DATABASE command was modified to accept optional keywords:

#4698

Note that CREATE DATABASE currently takes optional IF NOT EXISTS keywords, so you might like to check out that code too. I guess the full command is something like:

CREATE DATABASE NOAA_water_database [ [ WITH RETENTION 24hr] [IF NOT EXISTS] ]

@otoolep
Copy link
Contributor

otoolep commented Nov 11, 2015

Once the parsing and AST code has been completed, it's pretty easy to work with the CreateDatabase type, and just check for the presence of the require attibutes, and when creating the database, create the retention policy (today that is checked via a flag in the meta package, which is what @pauldix doesn't like).

@pires
Copy link
Contributor

pires commented Nov 12, 2015

@otoolep thank you so much! Seems really doable even for a (Go and InfluxDB) newbie like me.

Some questions though:

  • The syntax seems to be CREATE DATABASE [IF NOT EXISTS] <database_name>. Or is the parser smart enough to accept options after the name?
  • Should we follow time.ParseDuration(string) spec and use 24h instead of 24hr. Probably your example has a typo but want to make sure before jumping in.

@otoolep
Copy link
Contributor

otoolep commented Nov 12, 2015

@pires -- actually if you checked the code you are right, I got it backwards. The parser is not smart, and will error if you supply what I thought it was.

As for the time spec, I was just being brief. Yes, it should follow the Go spec as you suggest.

@pires
Copy link
Contributor

pires commented Nov 12, 2015

@otoolep owning it. Should I report back to this issue?

@otoolep
Copy link
Contributor

otoolep commented Nov 12, 2015

So I am guessing we want:

CREATE DATABASE [IF NOT EXISTS] NOAA_water_database [ WITH RETENTION 24hr ]

To be honest, once you know how to add commands to the parser it's not a big deal to modify if we change our mind during development.

@otoolep
Copy link
Contributor

otoolep commented Nov 12, 2015

That sounds good, thanks @pires

@pires
Copy link
Contributor

pires commented Nov 12, 2015

To be honest, once you know how to add commands to the parser it's not a big deal to modify if we change our mind during development.

Yes, your pointers made whoever takes this task life easier. Again, I'm going for it. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration difficulty/medium Resolving this issue should take up to a week
Projects
None yet
Development

No branches or pull requests

10 participants