Warn if cache size of lookup is beyond max size#11863
Warn if cache size of lookup is beyond max size#11863zachjsh merged 12 commits intoapache:masterfrom
Conversation
|
This pull request introduces 2 alerts when merging d38e711 into 90640bb - view on LGTM.com new alerts:
|
| }, | ||
| "pollPeriod":"PT5M" | ||
| "pollPeriod":"PT5M", | ||
| "maxSize": 5242880 |
There was a problem hiding this comment.
I think it'd make more sense to express this as a percentage of available heap instead of a fixed byte limit, since the amount of available memory can differ across the various nodes where lookups might be loaded
There was a problem hiding this comment.
Good suggestion, fixed.
| if ((key instanceof String) && (value instanceof String)) { | ||
| return ((String) (key)).length() + ((String) (value)).length(); | ||
| } else { | ||
| LOG.warn( |
There was a problem hiding this comment.
Are there cases where the value is not a string? If so, suggest adding support for those cases, this log seems likely to result in excessive logging since it's per entry
There was a problem hiding this comment.
thanks for suggestion, should be fixed now.
There was a problem hiding this comment.
can you adjust so that it doesn't potentially log on every value
There was a problem hiding this comment.
See comment in populate function // this top level check so that we dont keep logging inability to determine
Description
Enhanced the
ExtractionNamespaceinterface inlookups-cached-globalcore extension with the ability to set amaxHeapPercentagefor the cache of the respective namespace. The reason for adding this functionality, is make it easier to detect when a lookup table grows to a size that the underlying service cannot handle, because it does not have enough memory. The default value of maxHeap for the interface is -1, which indicates that no maxHeapPercentage has been set. For theJdbcExtractionNamespaceandUriExtractionNamespaceimplementations, the default value is null, which will cause the respective service that the lookup is loaded in, to warn when its cache is beyondmxHeapPercentageof the service's configured max heap size. If a positive non-null value is set for the namespace'smaxHeapPercentageconfig, this value will be honored for all services that the respective lookup is loaded onto, and consequently log warning messages when the cache of the respective lookup grows beyond this respective percentage of the services configured max heap size. Warnings are logged every time that either Uri based or Jdbc based lookups are regenerated, if themaxHeapPercentageconstraint is violated. No other implementations will log warnings at this time. No error is thrown when the size exceeds the maxHeapPercentage at this time, as doing so could break functionality for existing users. Previously theJdbcCacheGeneratorgenerated its cache by materializing all rows of the underling table in memory at once; this made it difficult to log warning messages in the case that the results from the jdbc query were very large and caused the service to run out of memory. To help with this, this pr makes it so that the jdbc query results are instead streamed through an iterator.This PR has: