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

Clean up shard data when dropping retention policies #5691

Merged
merged 1 commit into from
Feb 19, 2016

Conversation

e-dard
Copy link
Contributor

@e-dard e-dard commented Feb 15, 2016

Fixes #5653.

  • Adds methods on the tsdb.Store for deleting shards in a retention policy, and cleaning up said retention policy.
  • Refactors tsdb.Store.DeleteDatabase so that it does not require the ids of the shards within the database.
  • Wires up deleting retention policy with the query executor (for the moment).

@e-dard e-dard force-pushed the er-retention-policies branch from ada132a to f57e2a0 Compare February 15, 2016 14:29
@jwilder
Copy link
Contributor

jwilder commented Feb 15, 2016

Looks like this will fix #5394 as well.

@@ -252,6 +261,7 @@ func (s *Store) CreateShard(database, retentionPolicy string, shardID uint64) er
}

s.shards[shardID] = shard
s.shardLocations[shardID] = &shardLocation{Database: database, RetentionPolicy: retentionPolicy, Shard: shard}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to just combine shards and shardLocations maps? shardLocation has a pointer to the Shard which is all that shards has.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that was my thinking, but I wanted to get feedback on whether it's OK to do away with shards first. Seems I forgot to even mention that in the PR description 😄, so thanks for bring it up!

I'll refactor this morning.

@e-dard e-dard force-pushed the er-retention-policies branch 2 times, most recently from 9e73c57 to be78c8c Compare February 18, 2016 16:54
@e-dard e-dard changed the title [WIP] Drop retention policy Clean up shard data when dropping retention policies Feb 18, 2016
@e-dard e-dard force-pushed the er-retention-policies branch from be78c8c to 241a92b Compare February 18, 2016 16:57
for _, sh := range s.shards {
s.performMaintenanceOnShard(sh)
for _, sl := range s.shardLocations {
s.performMaintenanceOnShard(sl.Shard)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to check that sl.Shard is not nil as well? It's done in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, yeah. To be honest a shardLocation shouldn't have a nil Shard, but better to be defensive 👍

@jwilder
Copy link
Contributor

jwilder commented Feb 18, 2016

One last item. But 👍 after that.

@e-dard e-dard force-pushed the er-retention-policies branch from 241a92b to 012b89c Compare February 18, 2016 17:06
for _, sh := range s.shards {
if err := sh.Close(); err != nil {
for _, sl := range s.shardLocations {
if err := sl.Shard.Close(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly check for nil? Although NewShard() currently never returns nil, and that appears to be the only value that gets stored in sl.Shard, I see that you've checked for nil in other places for this field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, (*Shard).Close() can be updated to handle a nil receiver.

Fixes #5653 and #5394.

Previously dropping retention policies did not propogate to local TSDB
shards. Instead, the retention policiess would just be removed from the
Meta Store.

This PR adds ensures that data associated with retention policies is
removed, when the retention policy is dropped.

Also, it cleans up a couple of other methods in `tsdb`, including the
requirement to provide (redundant) shardIDs when deleting databases.
@e-dard e-dard force-pushed the er-retention-policies branch from 012b89c to 99a7341 Compare February 19, 2016 11:15
@e-dard
Copy link
Contributor Author

e-dard commented Feb 19, 2016

Discussed defensive nil shard checks with @joelegasse and @jwilder, and we decided to remove them as they should be redundant.

e-dard added a commit that referenced this pull request Feb 19, 2016
Clean up shard data when dropping retention policies
@e-dard e-dard merged commit 2da8321 into master Feb 19, 2016
@e-dard e-dard deleted the er-retention-policies branch February 19, 2016 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants