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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
- [#5666](https://github.com/influxdata/influxdb/pull/5666): Manage dependencies with gdm
- [#5512](https://github.com/influxdata/influxdb/pull/5512): HTTP: Add config option to enable HTTP JSON write path which is now disabled by default.
- [#5336](https://github.com/influxdata/influxdb/pull/5366): Enabled golint for influxql. @gabelev
- [#5706](https://github.com/influxdata/influxdb/pull/5706): Cluster setup
cleanup
- [#5706](https://github.com/influxdata/influxdb/pull/5706): Cluster setup cleanup
- [#5691](https://github.com/influxdata/influxdb/pull/5691): Remove associated shard data when retention policies are dropped.

### Bugfixes

Expand Down
27 changes: 16 additions & 11 deletions cluster/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,29 @@ func (e *QueryExecutor) executeDropDatabaseStatement(stmt *influxql.DropDatabase
return err
}

// Retrieve a list of all shard ids.
var shardIDs []uint64
for _, rp := range dbi.RetentionPolicies {
for _, sg := range rp.ShardGroups {
for _, s := range sg.Shards {
shardIDs = append(shardIDs, s.ID)
}
}
}

// Remove the database from the local store
if err := e.TSDBStore.DeleteDatabase(stmt.Name, shardIDs); err != nil {
if err := e.TSDBStore.DeleteDatabase(stmt.Name); err != nil {
return err
}

return nil
}

// executeDropRetentionPolicy closes all local shards for the retention
// policy and removes the directory.
func (q *QueryExecutor) executeDropRetentionPolicy(stmt *influxql.DropRetentionPolicyStatement) error {
// Check if the database and retention policy exist.
if _, err := q.MetaClient.RetentionPolicy(stmt.Database, stmt.Name); err != nil {
return err
}

// Remove the retention policy from the local store.
if err := q.TSDBStore.DeleteRetentionPolicy(stmt.Database, stmt.Name); err != nil {
return err
}
return q.MetaClient.DropRetentionPolicy(stmt.Database, stmt.Name)
}

func (e *QueryExecutor) executeDropMeasurementStatement(stmt *influxql.DropMeasurementStatement, database string) error {
return e.TSDBStore.DeleteMeasurement(database, stmt.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion services/meta/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func (c *Client) RetentionPolicy(database, name string) (rpi *RetentionPolicyInf

// TODO: This should not be handled here
if db == nil {
return nil, ErrDatabaseNotExists
return nil, influxdb.ErrDatabaseNotFound(database)
}

return db.RetentionPolicy(name), nil
Expand Down
Loading