Drop measurement was taking to long due to transactions
parent
6ecf084c89
commit
dc1a103ec9
10
database.go
10
database.go
|
@ -1128,10 +1128,8 @@ func (db *database) dropMeasurement(name string) error {
|
|||
|
||||
// remove series data from shards
|
||||
for _, rp := range db.policies {
|
||||
for _, id := range ids {
|
||||
if err := rp.dropSeries(id); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := rp.dropSeries(ids...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1139,9 +1137,9 @@ func (db *database) dropMeasurement(name string) error {
|
|||
}
|
||||
|
||||
// dropSeries will delete all data with the seriesID
|
||||
func (rp *RetentionPolicy) dropSeries(seriesID uint32) error {
|
||||
func (rp *RetentionPolicy) dropSeries(seriesIDs ...uint32) error {
|
||||
for _, g := range rp.shardGroups {
|
||||
err := g.dropSeries(seriesID)
|
||||
err := g.dropSeries(seriesIDs...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
14
shard.go
14
shard.go
|
@ -45,9 +45,9 @@ func (g *ShardGroup) Contains(min, max time.Time) bool {
|
|||
}
|
||||
|
||||
// dropSeries will delete all data with the seriesID
|
||||
func (g *ShardGroup) dropSeries(seriesID uint32) error {
|
||||
func (g *ShardGroup) dropSeries(seriesIDs ...uint32) error {
|
||||
for _, s := range g.Shards {
|
||||
err := s.dropSeries(seriesID)
|
||||
err := s.dropSeries(seriesIDs...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -201,14 +201,16 @@ func (s *Shard) writeSeries(index uint64, batch []byte) error {
|
|||
})
|
||||
}
|
||||
|
||||
func (s *Shard) dropSeries(seriesID uint32) error {
|
||||
func (s *Shard) dropSeries(seriesIDs ...uint32) error {
|
||||
if s.store == nil {
|
||||
return nil
|
||||
}
|
||||
return s.store.Update(func(tx *bolt.Tx) error {
|
||||
err := tx.DeleteBucket(u32tob(seriesID))
|
||||
if err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
for _, seriesID := range seriesIDs {
|
||||
err := tx.DeleteBucket(u32tob(seriesID))
|
||||
if err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue