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
parent
ddf7f0fd7b
commit
5e342a2ddd
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue