-
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
Don't precreate shard groups entirely in past #3931
Conversation
c3f906f
to
2199aca
Compare
Nice! Good optimization. +1 on green. |
1b42576
to
e32d871
Compare
The Also, cutoff time doesn't make sense to me. I think it's easier to understand if it something like this inside the loop of the replication policies. mostRecentShard := rp.ShardGroups[len(rp.ShardGroups)-1]
nearFuture := time.Now.Add(2 * time.Hour).Unix()
if nearFuture > mostRecentShard.EndTime.Unix() {
// create the shard group
} |
@pauldix -- Let me see if I can simplify it by looking at only the last shard group in the RP. |
Shard groups are not stored in a sorted manner, that I can see. https://github.com/influxdb/influxdb/blob/master/meta/data.go#L353 and the function which returns ShardGroups on an RPI, doesn't seem to sort them either: https://github.com/influxdb/influxdb/blob/master/meta/data.go#L241 We might need some more changes here, such that the Precreate function can be simplified. I can do that in a separate PR. |
Yeah, since shard groups are rarely created, and they almost always need to On Tue, Sep 1, 2015 at 3:37 PM, otoolep notifications@github.com wrote:
|
Agreed @pauldix -- the case for storing these sorted makes sense to me. Let me see what I can do. |
569fee6
to
ca6460f
Compare
Logic updated now that shard groups are sorted by time. Removes one |
46bee69
to
0a8acb3
Compare
s.Logger.Printf("new shard group %d successfully created for database %s, retention policy %s", | ||
newGroup.ID, di.Name, rp.Name) | ||
} | ||
if len(rp.ShardGroups) == 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.
A comment here would be useful. When would len(rp.ShardGroups) == 0
? Is this basically checking to make sure that the retention policy has been written to at least once before pre-creating shard groups?
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, exactly. Or all shard groups have been expired out.
0a8acb3
to
c5c2e81
Compare
Two small smalls things but otherwise 👍 |
c5c2e81
to
06152ba
Compare
Thanks @jwilder -- will merge on green. |
Don't precreate shard groups entirely in past
If a shard group is completely in the past, don't precreate its successor. Before this fix, this could happen if someone wrote a single point into the past, which means a shard group was created for that point, and then precreation would create the entire successor series of groups.
Fixes issue #3722