You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Thomas Mueller (JIRA)" <ji...@apache.org> on 2017/06/19 14:55:00 UTC

[jira] [Commented] (OAK-6359) Change behavior for very complex queries

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

Thomas Mueller commented on OAK-6359:
-------------------------------------

http://svn.apache.org/r1799219 (trunk)

Limit the XPath -> SQL-2 conversion to at most create 1000 union statements. This is to ensure parsing a query doesn't run out of memory. When going over this limit, the query is converted as is, that means, no "union" statement is made (instead, the SQL-2 query uses "or" conditions just like the XPath query). That means possibly no index can be used. The behavior of such cases is already limited (with traversal limit for example). It still needs to be tested if the SQL-2 query doesn't result in a memory problem, due to possible conversion to union there.

> Change behavior for very complex queries
> ----------------------------------------
>
>                 Key: OAK-6359
>                 URL: https://issues.apache.org/jira/browse/OAK-6359
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: query
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>            Priority: Critical
>             Fix For: 1.8, 1.7.3
>
>
> Very complex queries can cause take a long time to parse, and can possibly cause OOME. It would be good if processing queries automatically stops after some number of loops, after some time, or some amount of memory was used. And then throw an exception "query too complex".
> Example query:
> {noformat}
> //element(*,rep:Authorizable)[ ( (  
>  jcr:like(fn:lower-case(fn:name()), 'audio%')
>  or jcr:contains(@rep:principalName,'audio*')
>  or jcr:contains(@cq:first-name,'audio*')
>  or jcr:contains(@cq:last-name,'audio*')
>  or jcr:contains(profile/@givenName,'audio*')
>  or jcr:contains(profile/@familyName,'audio*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'conference%')
>  or jcr:contains(@rep:principalName,'conference*')
>  or jcr:contains(@cq:first-name,'conference*')
>  or jcr:contains(@cq:last-name,'conference*')
>  or jcr:contains(profile/@givenName,'conference*')
>  or jcr:contains(profile/@familyName,'conference*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'details:%')
>  or jcr:contains(@rep:principalName,'details:*')
>  or jcr:contains(@cq:first-name,'details:*')
>  or jcr:contains(@cq:last-name,'details:*')
>  or jcr:contains(profile/@givenName,'details:*')
>  or jcr:contains(profile/@familyName,'details:*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'conference%')
>  or jcr:contains(@rep:principalName,'conference*')
>  or jcr:contains(@cq:first-name,'conference*')
>  or jcr:contains(@cq:last-name,'conference*')
>  or jcr:contains(profile/@givenName,'conference*')
>  or jcr:contains(profile/@familyName,'conference*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'code:%')
>  or jcr:contains(@rep:principalName,'code:*')
>  or jcr:contains(@cq:first-name,'code:*')
>  or jcr:contains(@cq:last-name,'code:*')
>  or jcr:contains(profile/@givenName,'code:*')
>  or jcr:contains(profile/@familyName,'code:*') )
>  and (  jcr:like(fn:lower-case(fn:name()), '123456%')
>  or jcr:contains(@rep:principalName,'123456*')
>  or jcr:contains(@cq:first-name,'123456*')
>  or jcr:contains(@cq:last-name,'123456*')
>  or jcr:contains(profile/@givenName,'123456*')
>  or jcr:contains(profile/@familyName,'123456*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'further%')
>  or jcr:contains(@rep:principalName,'further*')
>  or jcr:contains(@cq:first-name,'further*')
>  or jcr:contains(@cq:last-name,'further*')
>  or jcr:contains(profile/@givenName,'further*')
>  or jcr:contains(profile/@familyName,'further*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'dial%')
>  or jcr:contains(@rep:principalName,'dial*')
>  or jcr:contains(@cq:first-name,'dial*')
>  or jcr:contains(@cq:last-name,'dial*')
>  or jcr:contains(profile/@givenName,'dial*')
>  or jcr:contains(profile/@familyName,'dial*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'in%')
>  or jcr:contains(@rep:principalName,'in*')
>  or jcr:contains(@cq:first-name,'in*')
>  or jcr:contains(@cq:last-name,'in*')
>  or jcr:contains(profile/@givenName,'in*')
>  or jcr:contains(profile/@familyName,'in*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'numbers:%')
>  or jcr:contains(@rep:principalName,'numbers:*')
>  or jcr:contains(@cq:first-name,'numbers:*')
>  or jcr:contains(@cq:last-name,'numbers:*')
>  or jcr:contains(profile/@givenName,'numbers:*')
>  or jcr:contains(profile/@familyName,'numbers:*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'http://wikipedia.org%')
>  or jcr:contains(@rep:principalName,'http://wikipedia.org*')
>  or jcr:contains(@cq:first-name,'http://wikipedia.org*')
>  or jcr:contains(@cq:last-name,'http://wikipedia.org*')
>  or jcr:contains(profile/@givenName,'http://wikipedia.org*')
>  or jcr:contains(profile/@familyName,'http://wikipedia.org*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'conference%')
>  or jcr:contains(@rep:principalName,'conference*')
>  or jcr:contains(@cq:first-name,'conference*')
>  or jcr:contains(@cq:last-name,'conference*')
>  or jcr:contains(profile/@givenName,'conference*')
>  or jcr:contains(profile/@familyName,'conference*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'number(s):%')
>  or jcr:contains(@rep:principalName,'number(s):*')
>  or jcr:contains(@cq:first-name,'number(s):*')
>  or jcr:contains(@cq:last-name,'number(s):*')
>  or jcr:contains(profile/@givenName,'number(s):*')
>  or jcr:contains(profile/@familyName,'number(s):*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'emea:%')
>  or jcr:contains(@rep:principalName,'emea:*')
>  or jcr:contains(@cq:first-name,'emea:*')
>  or jcr:contains(@cq:last-name,'emea:*')
>  or jcr:contains(profile/@givenName,'emea:*')
>  or jcr:contains(profile/@familyName,'emea:*') )
>  and (  jcr:like(fn:lower-case(fn:name()), '%')
>  or jcr:contains(@rep:principalName,'*')
>  or jcr:contains(@cq:first-name,'*')
>  or jcr:contains(@cq:last-name,'*')
>  or jcr:contains(profile/@givenName,'*')
>  or jcr:contains(profile/@familyName,'*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'test%')
>  or jcr:contains(@rep:principalName,'test*')
>  or jcr:contains(@cq:first-name,'test*')
>  or jcr:contains(@cq:last-name,'test*')
>  or jcr:contains(profile/@givenName,'test*')
>  or jcr:contains(profile/@familyName,'test*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'to%')
>  or jcr:contains(@rep:principalName,'to*')
>  or jcr:contains(@cq:first-name,'to*')
>  or jcr:contains(@cq:last-name,'to*')
>  or jcr:contains(profile/@givenName,'to*')
>  or jcr:contains(profile/@familyName,'to*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'join%')
>  or jcr:contains(@rep:principalName,'join*')
>  or jcr:contains(@cq:first-name,'join*')
>  or jcr:contains(@cq:last-name,'join*')
>  or jcr:contains(profile/@givenName,'join*')
>  or jcr:contains(profile/@familyName,'join*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'the%')
>  or jcr:contains(@rep:principalName,'the*')
>  or jcr:contains(@cq:first-name,'the*')
>  or jcr:contains(@cq:last-name,'the*')
>  or jcr:contains(profile/@givenName,'the*')
>  or jcr:contains(profile/@familyName,'the*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'meeting:%')
>  or jcr:contains(@rep:principalName,'meeting:*')
>  or jcr:contains(@cq:first-name,'meeting:*')
>  or jcr:contains(@cq:last-name,'meeting:*')
>  or jcr:contains(profile/@givenName,'meeting:*')
>  or jcr:contains(profile/@familyName,'meeting:*') )
>  and (  jcr:like(fn:lower-case(fn:name()), 'http://wikipedia.org%')
>  or jcr:contains(@rep:principalName,'http://wikipedia.org*')
>  or jcr:contains(@cq:first-name,'http://wikipedia.org*')
>  or jcr:contains(@cq:last-name,'http://wikipedia.org*')
>  or jcr:contains(profile/@givenName,'http://wikipedia.org*')
>  or jcr:contains(profile/@familyName,'http://wikipedia.org*') ) ) ] 
>  order by @rep:principalName
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)