Ensure shared index removed on database drop

When using the inmem index, if one drops a database, and then creates it
again, the previous index object will be reused. This includes the
previous cardinality estimation sketches, leading to inaccurate
cardinality estimations.
pull/8228/head
Edd Robinson 2017-03-30 13:05:31 +01:00
parent ddf7f0fd7b
commit 5e342a2ddd
1 changed files with 6 additions and 1 deletions

View File

@ -278,7 +278,9 @@ func (s *Store) Close() error {
return nil return nil
} }
// createIndexIfNotExists returns an index for a database. // createIndexIfNotExists returns a shared index for a database, if the inmem
// index is being used. If the TSI index is being used, then this method is
// basically a no-op.
func (s *Store) createIndexIfNotExists(name string) (interface{}, error) { func (s *Store) createIndexIfNotExists(name string) (interface{}, error) {
if idx := s.indexes[name]; idx != nil { if idx := s.indexes[name]; idx != nil {
return idx, nil return idx, nil
@ -480,6 +482,9 @@ func (s *Store) DeleteDatabase(name string) error {
// Remove database from store list of databases // Remove database from store list of databases
delete(s.databases, name) delete(s.databases, name)
// Remove shared index for database if using inmem index.
delete(s.indexes, name)
s.mu.Unlock() s.mu.Unlock()
return nil return nil