datawave
datawave copied to clipboard
QueryMetrics writing should handle query parse error better
Queries that contain lucene functions that are not configured in the LuceneToJexlQueryParser will cause an NPE in ContentQueryMetricsIngestHelper which is not caught locally enough to allow the query metric to continue being written. QueryMetrics with Lifecycle NONE were observed. Any query that fails to parse would cause the same issue.
This happened because the code was using a default LuceneToJexlQueryParser which contained a default set of allowedFunctions. If the QueryLogicFactory.xml defined allowedFunctions has entries that are not in the default list (see #1547), then this issue will occur.
- Inject the LuceneToJexlQueryParser @SpringBean into the ShardTableQueryMetricHandler
- Better define when POSITIVE_SELECTORS and NEGATIVE_SELECTORS should be extracted (was using numUpdates)
- Ensure that numUpdates is being properly updates
- Catch Exception when parsing the query to extract POSITIVE_SELECTORS and NEGATIVE_SELECTORS
- Move parsing from ContentQueryMetricsIngestHelper to BaseQueryMetricHandler, allowing the cached QueryMetric to be updated
Separately -- another issue should look at the LuceneToJexlQueryParser used for selector eextraction for audit purposes (DatawaveSelectorExtractor also uses the default allowedFunctions)