-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Added support for configurable default retention policy on database creation #4866
Conversation
Is the following error related to what I did? Seems not.
Also, I think I should add tests to validate the default retention policy is properly set on all shards when we use |
I took a quick look at this. I'm not sure why you followed this approach of modifying the function |
@otoolep both have crossed my mind but then I looked at
Or am missing something? |
After creating the database, can we not just call We tend to leave simple functions, like |
@otoolep just to make sure, we're talking about the |
Yes, in the sense the idea is if they supply a retention policy duration with the statement, it's applied to the auto-gen default retention. I do think some of this is not quite clear in our heads, since there might be some edge cases with the auto-gen functionality that is there now. |
@otoolep default retention policy auto-gen happens inside |
Ideally, since @pauldix prefers a statement-based approach to this, I think he needs to decide if we can break the old behaviour. The answer may be no, so the solution may be messier. I think |
@otoolep I'm glad to be involved in the feature-design process. My (easy) choice is to break the old behavior and make database creation dictate the default retention policy, if any. |
Perhaps just a new call |
@otoolep yes, it's a prettier solution indeed. Should I wait on more feedback, namely from Paul or get on with it? |
I'd say no breaking change. Ideally the statement would include the other part of a retention policy, which is the replication factor. I think |
We should offer the ability to specify a retention policy name as well, so this could be used beyond just the |
@corylanou but that's what |
Yes, but since this is very close to that, it would be nice if we supported creating a database and a retention policy, and be able to name them both. Many users may have historical reasons for not wanting to have the default RP named |
@corylanou how different is having what you suggest and the user running both |
Maybe I'm missing the point of this PR. You could always run two commands to get the same result as above. For me, this is a single command that combines creating a database and retention policy in one command. I'm not sure why we would limit that to just creating a default RP if we go through all the work. |
@corylanou please see #2676. I'm putting this on hold until we all agree on what to deliver. |
So I understand why we originally started this PR based on issue #2676. I always try to make sure to look at the bigger picture when making language changes. Also, since making a change to this particular statement later to support any RP, not just default, could result in a |
Yeah, reading the ticket is the best way to get up to speed on all the work @pires has being doing for us. The executive summary: -- autocreation of a default retention policy is a useful feature. |
So I understand why this PR came into existence, and the history behind it. My point is we are making a change to the query language that can with just a couple modifications support more than just |
I believe I follow you @corylanou However, I don't consider this a breaking change. How is it breaking? The extra params are optional. |
He's saying if we push this as is and then later decide we want to give people the option to add a name for this default retention policy, that later change would be breaking. I'm in support of having the name be something they can specify. However, @corylanou's concern is covered in his syntax. If we decide to let them specify name later then it would simply add another optional argument
Looking at the code it seems that the support for specifying the replication factor still needs to be added in so the. The function definitions for Thanks for all your work @pires. I think your new syntax is a good idea along with an update that I just mentioned. Does all that make sense? @corylanou and @otoolep, you guys on board or are there still concerns? |
My concerns are addressed. Thanks! |
@@ -997,7 +996,7 @@ func (s *Store) Databases() (dis []DatabaseInfo, err error) { | |||
} | |||
|
|||
// CreateDatabase creates a new database in the store. | |||
func (s *Store) CreateDatabase(name string) (*DatabaseInfo, error) { | |||
func (s *Store) CreateDatabase(name string, retentionPeriod time.Duration) (*DatabaseInfo, error) { |
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.
Just to we're clear, @pauldix is saying this should be RetentionPolicyInfo type, not just a duration.
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.
Thank you for making sure I got it right ;)
Thank you @corylanou @otoolep and @pauldix for sharing the discussion that led to the following design decision:
I'm resuming the PR now. |
@pauldix @otoolep @corylanou while implementing the parsing stuff I started wondering if |
I think |
@pauldix I don't. Fixing tests and will update the PR for your review. |
@pauldix @otoolep @corylanou please review updated PR. |
_, _ = buf.WriteString(s.RetentionPolicyDuration.String()) | ||
_, _ = buf.WriteString("REPLICATION ") | ||
_, _ = buf.WriteString(strconv.Itoa(s.RetentionPolicyReplication)) | ||
_, _ = buf.WriteString("NAME ") |
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.
What will this render if NAME
is not set?
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.
Will it render a statement that is actually syntactically incorrect?
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.
Oh, I see, it will set it to "default". OK.
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.
Yes, default
.
Looks great @pires -- thanks for sticking with us. I'd like one small change made (the variable renamed) but I don't need to review again. +1. |
Thank you @otoolep, nits addressed. |
Any updates on this? |
This is great, thanks @pires! |
Added support for configurable default retention policy on database creation
@pauldix my pleasure. I've been learning a lot from you, @otoolep and @corylanou. |
Adds support for:
Fixes #2676