Don't return error for non-existent series file

When dropping series, if the series file does not exists we returned
and error.  This breaks compatibility with prior versions that would
not return an error if the series do not exists.
pull/9311/head
Jason Wilder 2018-01-14 12:53:26 -07:00
parent 9418d373d6
commit 874d5839da
2 changed files with 20 additions and 1 deletions

View File

@ -970,7 +970,8 @@ func (s *Store) DeleteSeries(database string, sources []influxql.Source, conditi
sfile := s.sfiles[database]
if sfile == nil {
return fmt.Errorf("unable to locate series file for database: %q", database)
// No series file means nothing has been written to this DB and thus nothing to delete.
return nil
}
shards := s.filterShards(byDatabase(database))

View File

@ -140,6 +140,24 @@ func TestStore_CreateShard(t *testing.T) {
}
}
// Ensure the store does not return an error when delete from a non-existent db.
func TestStore_DeleteSeries_NonExistentDB(t *testing.T) {
t.Parallel()
test := func(index string) {
s := MustOpenStore(index)
defer s.Close()
if err := s.DeleteSeries("db0", nil, nil, true); err != nil {
t.Fatal(err.Error())
}
}
for _, index := range tsdb.RegisteredIndexes() {
t.Run(index, func(t *testing.T) { test(index) })
}
}
// Ensure the store can delete an existing shard.
func TestStore_DeleteShard(t *testing.T) {
t.Parallel()