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

RUnlock server after dropping series #2441

Merged
merged 3 commits into from
Apr 27, 2015
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
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## v0.9.0-rc28 [unreleased]

### Features
- [#2410](https://github.com/influxdb/influxdb/pull/2410) Allow configuration of Raft timers

### Bugfixes
- [#2374](https://github.com/influxdb/influxdb/issues/2374): Two different panics during SELECT percentile
- [#2404](https://github.com/influxdb/influxdb/pull/2404): Mean and percentile function fixes
Expand All @@ -11,9 +14,7 @@
- [#2426](https://github.com/influxdb/influxdb/pull/2426): Fix race condition around listener address in Graphite server.
- [#2429](https://github.com/influxdb/influxdb/pull/2429): Ensure no field value is null.
- [#2431](https://github.com/influxdb/influxdb/pull/2431): Always append shard path in diags. Thanks @marcosnils

### Features
- [#2410](https://github.com/influxdb/influxdb/pull/2410) Allow configuration of Raft timers
- [#2441](https://github.com/influxdb/influxdb/pull/2441): Correctly release server RLock during "drop series".

## v0.9.0-rc27 [04-23-2015]

Expand Down
84 changes: 45 additions & 39 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2499,59 +2499,65 @@ func (s *Server) executeDropMeasurementStatement(stmt *influxql.DropMeasurementS
}

func (s *Server) executeDropSeriesStatement(stmt *influxql.DropSeriesStatement, database string, user *User) *Result {
s.mu.RLock()
seriesByMeasurement, err := func() (map[string][]uint64, error) {
// Using a local function makes lock management foolproof.
s.mu.RLock()
defer s.mu.RUnlock()

seriesByMeasurement := make(map[string][]uint64)
// Handle the simple `DROP SERIES <id>` case.
if stmt.Source == nil && stmt.Condition == nil {
for _, db := range s.databases {
for _, m := range db.measurements {
if m.seriesByID[stmt.SeriesID] != nil {
seriesByMeasurement[m.Name] = []uint64{stmt.SeriesID}
seriesByMeasurement := make(map[string][]uint64)
// Handle the simple `DROP SERIES <id>` case.
if stmt.Source == nil && stmt.Condition == nil {
for _, db := range s.databases {
for _, m := range db.measurements {
if m.seriesByID[stmt.SeriesID] != nil {
seriesByMeasurement[m.Name] = []uint64{stmt.SeriesID}
}
}
}

return seriesByMeasurement, nil
}

s.mu.RUnlock()
return &Result{Err: s.DropSeries(database, seriesByMeasurement)}
}
// Handle the more complicated `DROP SERIES` with sources and/or conditions...

// Handle the more complicated `DROP SERIES` with sources and/or conditions...
// Find the database.
db := s.databases[database]
if db == nil {
return nil, ErrDatabaseNotFound(database)
}

// Find the database.
db := s.databases[database]
if db == nil {
s.mu.RUnlock()
return &Result{Err: ErrDatabaseNotFound(database)}
}
// Get the list of measurements we're interested in.
measurements, err := measurementsFromSourceOrDB(stmt.Source, db)
if err != nil {
return nil, err
}

// Get the list of measurements we're interested in.
measurements, err := measurementsFromSourceOrDB(stmt.Source, db)
if err != nil {
s.mu.RUnlock()
return &Result{Err: err}
}
for _, m := range measurements {
var ids seriesIDs
if stmt.Condition != nil {
// Get series IDs that match the WHERE clause.
filters := map[uint64]influxql.Expr{}
ids, _, _, err = m.walkWhereForSeriesIds(stmt.Condition, filters)
if err != nil {
return nil, err
}

for _, m := range measurements {
var ids seriesIDs
if stmt.Condition != nil {
// Get series IDs that match the WHERE clause.
filters := map[uint64]influxql.Expr{}
ids, _, _, err = m.walkWhereForSeriesIds(stmt.Condition, filters)
if err != nil {
return &Result{Err: err}
// TODO: check return of walkWhereForSeriesIds for fields
} else {
// No WHERE clause so get all series IDs for this measurement.
ids = m.seriesIDs
}

// TODO: check return of walkWhereForSeriesIds for fields
} else {
// No WHERE clause so get all series IDs for this measurement.
ids = m.seriesIDs
seriesByMeasurement[m.Name] = ids

}

seriesByMeasurement[m.Name] = ids
}
s.mu.RUnlock()
return seriesByMeasurement, nil
}()

if err != nil {
return &Result{Err: err}
}
return &Result{Err: s.DropSeries(database, seriesByMeasurement)}
}

Expand Down