Monitoring Low Memory When Querying
The query monitoring feature prevents out-of-memory exceptions from occurring when you execute queries or create indexes.
You enable this feature when you set
a critical-heap-percentage
attribute for the resource-manager element
in the cache.xml
file or by using the
cache.getResourceManager().setCriticalHeapPercentage(float heapPercentage)
API. When this feature is enabled and
heap memory usage exceeds
the threshold due to running a query or creating an index,
the resource manager throws an exception
and cancels the running query or index creation.
You can explicitly disable this feature by setting the system property gemfire.cache.DISABLE_QUERY_MONITOR_FOR_LOW_MEMORY
to true.
When system memory is low,
as determined by the critical heap percentage threshold defined in
the cache.xml
file or in the getResourceManager API,
queries will throw a QueryExecutionLowMemoryException
.
Any indexes that are in the process of being created will throw
an InvalidIndexException
with the message indicating the reason.
Partitioned Region Queries and Low Memory
Partitioned region queries are likely causes for out-of-memory exceptions. If query monitoring is enabled, partitioned region queries drop or ignore results that are being gathered by other servers if the executing server is low in memory.
Query-monitoring does not address a scenario in which a low-level collection is expanded while the partitioned region query is gathering results. For example, if a row is added and then causes a Java level collection or array to expand, it is possible to then encounter an out-of-memory exception. This scenario is rare and is only possible if the collection size itself expands before a low memory condition is met and then expands beyond the remaining available memory. As a workaround, in the event that you encounter this situation, you may be able to tune the system by additionally lowering the critical-heap-percentage
.