Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
New
Description
QueryCache seems estimating the cached query size using a constant, it will cause OOM error in some extreme cases where queries cached will use far more memories than assumed. (The default QueryCache tries to use only 5% of heap) One example of such memory-eating query is AutomatonQuery, it will each carry a RunAutomaton , which consumes a good amount of memory in exchange for the speed.
On the other hand, we actually have a good implementation of Accountable interface for AutomatonQuery (though it will become a bit more complicated later since this query will eventually be rewritten to something else), so maybe QueryCache could use those estimation directly (using an instanceof check)? Or moreover we could make all Query implement {Accountable}}, and maybe the default implementation could just be returning the current constant we're using, and only override the method of the potential troublesome queries?