diff --git a/CHANGELOG.md b/CHANGELOG.md index 362aee25f5a..141745caa0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ - [#8601](https://github.com/influxdata/influxdb/pull/8601): Fixed time boundaries for continuous queries with time zones. - [#8097](https://github.com/influxdata/influxdb/pull/8097): Return query parsing errors in CSV formats. +## v1.3.2 [unreleased] + +- [#8630](https://github.com/influxdata/influxdb/pull/8630): Prevent excessive memory usage when dropping series + ## v1.3.1 [unreleased] ### Bugfixes diff --git a/tsdb/store.go b/tsdb/store.go index 2cc51ac2cd0..4a6b414b45e 100644 --- a/tsdb/store.go +++ b/tsdb/store.go @@ -570,7 +570,13 @@ func (s *Store) DeleteMeasurement(database, name string) error { shards := s.filterShards(byDatabase(database)) s.mu.RUnlock() + // Limit to 1 delete for each shard since expanding the measurement into the list + // of series keys can be very memory intensive if run concurrently. + limit := limiter.NewFixed(1) return s.walkShards(shards, func(sh *Shard) error { + limit.Take() + defer limit.Release() + if err := sh.DeleteMeasurement([]byte(name)); err != nil { return err } @@ -834,6 +840,10 @@ func (s *Store) DeleteSeries(database string, sources []influxql.Source, conditi s.mu.RLock() defer s.mu.RUnlock() + // Limit to 1 delete for each shard since expanding the measurement into the list + // of series keys can be very memory intensive if run concurrently. + limit := limiter.NewFixed(1) + return s.walkShards(shards, func(sh *Shard) error { // Determine list of measurements from sources. // Use all measurements if no FROM clause was provided. @@ -852,6 +862,9 @@ func (s *Store) DeleteSeries(database string, sources []influxql.Source, conditi } sort.Strings(names) + limit.Take() + defer limit.Release() + // Find matching series keys for each measurement. var keys [][]byte for _, name := range names {