When a database is deleted, the corresponding directory structure is removed entirely, even if the index writer has not yet been closed. Due to the missing files, both attempts of closing the index and then rolling it back fail, which eventually leads to leak of resources, more specifically locks, due to a known bug in Lucene versions prior to 4.7.1. In result, the subsequent search requests to the same index will fail when recreated.
As a minimal approach, work around the problem by pulling out the reference to the write lock and release it.
When a database is deleted, the corresponding directory structure is removed entirely, even if the index writer has not yet been closed. Due to the missing files, both attempts of closing the index and then rolling it back fail, which eventually leads to leak of resources, more specifically locks, due to a known bug in Lucene versions prior to 4.7.1. In result, the subsequent search requests to the same index will fail when recreated.
As a minimal approach, work around the problem by pulling out the reference to the write lock and release it.