mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
When a SearchContext is closed it's reader / searcher reference is closed too. If this happens while a search is accessing it's reader reference it can lead to an unexpected `AlreadyClosedException` or worst case, an already closed MMapDirectory is access causing a `SIGSEV` like in #20008 (even though the window for this is very small). SearchContext can be closed concurrently if: * an index is deleted / removed from the node * a search context is idle for too long and is cleaned by the reaper * an explicit freeContext message is received This change adds reference counting to the SearchContext base class and it's used inside SearchService each time the context is accessed. Closes #20008