[ 
https://issues.apache.org/jira/browse/SLING-8407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16839144#comment-16839144
 ] 

Thomas Mueller commented on SLING-8407:
---------------------------------------

> Oak could expose an marker API (e.g. IndexReady) 

One issue not mentioned so far is race conditions: Assuming the code (A) checks 
if "index is ready", if yes (B) runs a query. What if the index becomes 
unavailable between A and B? I would rather go for the simpler, and saver 
option to mark the query itself.

>  requiring to pass option(traversal fail) to some queries couples Queries and 
> indexes

Yes, up to some point: it requires that an index can be used for the query, 
meaning there is a guarantee that the query returns within a reasonable time. 
It doesn't say which index exactly. (Actually it doesn't mean that the query 
may not traverse, if traversing is faster than using an index - it just means 
an index needs to be available.) I think it makes sense to set this as the 
default way to run queries. That means, if you run a query and forgot to add an 
index, then the query will fail. It's just that AEM as a whole isn't ready for 
this yet (too many things will break right now). And of course customer code 
will also break (backward compatibility). To enforce the query is run, one 
might use "option(traversal ok)", and my fear is that this would be added to 
too many queries as a short term solution.

Longer term, we could bind each query to a specific index tag using 
"option(index tag ...)", which ensures the right kind of index is used, but 
also not specifying which index exactly. [[email protected]] proposed this 
idea, and I think it would make a lot of sense. Unfortunately, it would also 
require many changes in AEM.



> JobManagerImpl.findJobs should prevent traversal
> ------------------------------------------------
>
>                 Key: SLING-8407
>                 URL: https://issues.apache.org/jira/browse/SLING-8407
>             Project: Sling
>          Issue Type: Improvement
>          Components: Event
>            Reporter: Thomas Mueller
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The method 
> [JobManagerImpl.findJobs|https://github.com/apache/sling-org-apache-sling-event/blob/master/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java#L373]
>  runs a JCR query to find all jobs for a topic.
> It is possible that such a query is running while the repository isn't 
> initialized yet, meaning while the index isn't available yet. What is 
> happening in this case is that the query is traversing all nodes below that 
> path, triggering a warning that the query doesn't use an index. It is 
> sometimes happening when a health check is running before the repository is 
> initialized (ReplicationQueueHealthCheck and DistributionQueueHealthCheck).
> It doesn't make sense that the query traverses the nodes. It should use an 
> index. If the index isn't available yet, it should fail. Therefore, the query 
> should use "option(traversal fail)". That would result in an exception that 
> can be caught.  I will log a related issue to change the health checks to 
> process this exception and return HEALTH_CHECK_ERROR for this case.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to