Forcing xpath query timeouts | Community
Skip to main content
roberth55706517
Level 4
Nov 26, 2018 6:14 PM UTC
Solved

Forcing xpath query timeouts

I have a client that is on AEM 6.2 and I am being asked to set timeouts on xpath searches. Looking at the documents for javax.jcr.query.QueryManager, I don't see any way to do this.

Is there a way to watch a query's execution time and kill the thread after X number of seconds?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Nov 26, 2018 8:08 PM UTC

Unfortunately that's not possible with the current implementation. But you can set limits how many nodes should be iterated at max.

Jörg

5 replies

joerghoh
Employee
Nov 26, 2018 10:25 PM UTC

I guess the only chance to mitigate that is not to kill long-running query but to avoid long-running queries at all. Of course with all combinations used you can create arbitrarily complex queries which take a long time to complete. But I am not really aware of immediate issues where the sidekick is unusable due to slow queries. If that's the case I would contact Adobe support.

Do you have any query which is created by sidekick and which is slow or which is traversing the tree instead of using an index?

Jörg

Translate
vipins5188
Level 3
Nov 26, 2018 9:07 PM UTC

Alternatively you can create oak indexes to optimise your query.

Translate
Ravi_Pampana
New Participant
Nov 26, 2018 8:47 PM UTC

Just a thought.

We can try doing multiple searches with limited nodes (1 call for each site) and append results. In this way, we can avoid additional calls if user leaves the page.

Translate
roberth55706517
Level 4
Nov 26, 2018 8:19 PM UTC

That is what I was afraid of. The client has a lot of sites and authors are dumping large numbers of assets, many could be duplicates so the search in the sidekick for assets takes a very long time to return results. Limit would help where assets are found, but not in the case where it takes a long time to complete. That is the biggest problem is limiting queries that take very long to complete. The user might leave the page but the queries run on, consuming CPU cycles that are no longer needed.

Translate
joerghoh
joerghohAccepted solution
Employee
Nov 26, 2018 8:08 PM UTC

Unfortunately that's not possible with the current implementation. But you can set limits how many nodes should be iterated at max.

Jörg

Translate