-
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
fix retention policy creation inconsistencies #7449
Conversation
@@ -12,7 +12,7 @@ type MetaClient interface { | |||
CreateContinuousQuery(database, name, query string) error | |||
CreateDatabase(name string) (*meta.DatabaseInfo, error) | |||
CreateDatabaseWithRetentionPolicy(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error) | |||
CreateRetentionPolicy(database string, spec *meta.RetentionPolicySpec) (*meta.RetentionPolicyInfo, error) | |||
CreateRetentionPolicy(database string, spec *meta.RetentionPolicySpec, makeDefault bool) (*meta.RetentionPolicyInfo, 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.
Not sure if I'm a fan of the word makeDefault
. I'm open to suggestions. setDefault
?
0317e92
to
5c7bb73
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.
Just the one small question, otherwise LGTM 👍
@@ -163,11 +163,21 @@ func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInf | |||
if rp.ReplicaN != rpi.ReplicaN || rp.Duration != rpi.Duration || rp.ShardGroupDuration != rpi.ShardGroupDuration { | |||
return ErrRetentionPolicyExists | |||
} | |||
// if they want to make it default, and it's not the default, it's not an identical command so it's an error | |||
if makeDefault && di.DefaultRetentionPolicy != rpi.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.
This may not make any sense, but what if they provide the same RP details as an existing default one, but they don't provide DEFAULT
? Should that be allowed, or is that an 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.
With my fix it is now an error. While we don't know why they would do this (although we can assume it was a mistake), we can't alter an RP via a create if it exists. You can only alter WITH an alter. The point of this code is so that if the create is issued with identical specifications, it's idempotent. The intent is to allow them to run the same scripts over and over for create database or retention policy without it erring out when the specifications are identical. If they change their script, then they will have to manually fix any changes to have it run in an idempotent manner again.
e4fcb6b
to
40d2ebd
Compare
40d2ebd
to
9da8b8d
Compare
9da8b8d
to
89b9002
Compare
89b9002
to
6e29004
Compare
@corylanou so now repeated CREATEs with the exact same syntax return a 204? But if there's any difference, they return a 40x? |
I would have to check what the server does as far as a status code. But certainly it will no longer work if there is any difference. |
Please let us know what the actual expected response is, so that we can appropriately document, thanks! |
This PR fixes inconsistent retention policy logic found in both
CreateDatabaseWithRetentionPolicy
,CreateRetentionPolicy
, andAlterRetentionPolicy
.I have also removed the
meta.SetDefaultRetentionPolicy
call as it should of never existed to begin with. All defaults should be set with the actual statement calls so they are atomic.Required for all non-trivial PRs
Required only if applicable
You can erase any checkboxes below this note if they are not applicable to your Pull Request.
fixes #7448