Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
9.0, 8.7, 8.8
-
None
-
New
Description
org.apache.lucene.monitor.Monitor can sometimes NOT match a document that should be matched by one of registered queries if match operations are run concurrently from multiple threads.
This is because sometimes in a concurrent environment TermFilteredPresearcher might not select a query that could later on match one of documents being matched.
Internally TermFilteredPresearcher is using a term acceptor: an instance of org.apache.lucene.monitor.QueryIndex.QueryTermFilter. QueryTermFilter is correctly initialized under lock and its internal state (a map of org.apache.lucene.util.BytesRefHash instances) is correctly published. Later one when those instances are used concurrently a problem with org.apache.lucene.util.BytesRefHash#find is triggered since it is not thread safe.
org.apache.lucene.util.BytesRefHash#find internally is using a private org.apache.lucene.util.BytesRefHash#equals method, which is using an instance field scratch1 as a temporary buffer to compare its ByteRef parameter with contents of ByteBlockPool. This is not thread safe and can cause incorrect answers as well as ArrayOutOfBoundException.
__