OAK Query Aborted

Evgeniy Fitsner Software Engineer
2 min read
OAK Query Aborted

The Problem

Every Adobe Experience Manager developer eventually encounters an exception indicating that the node reading limit has been exceeded:

1
2
3
4
5
java.lang.UnsupportedOperationException: The query read or traversed more than 100000 nodes.
To avoid affecting other tasks, processing was stopped.
	at org.apache.jackrabbit.oak.query.FilterIterators.checkReadLimit(FilterIterators.java:70)
	at org.apache.jackrabbit.oak.plugins.index.Cursors.checkReadLimit(Cursors.java:67)
	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$LucenePathCursor$1.next(LucenePropertyIndex.java:1730)

This error occurs when a JCR-SQL2 or XPath query reads or traverses more than 100,000 nodes without finding an applicable index. Oak aborts the query to prevent it from degrading system performance.

Root Causes

  • Missing index: No Oak index covers the properties used in the query WHERE clause.
  • Missing path restriction: The query lacks ISDESCENDANTNODE or ISCHILDNODE, causing a full repository scan.
  • Leading wildcards: Using LIKE '%term%' forces a traversal since standard property indexes cannot satisfy leading wildcard patterns.
  • Inefficient node types: Querying nt:unstructured or sling:OrderedFolder when a more specific type would suffice.

Solutions

Production Fixes

  1. Define an Oak index for the properties used in your query. Create a property index for equality lookups or a Lucene index for full-text search.

  2. Add a path restriction to every query using ISDESCENDANTNODE or ISCHILDNODE. This limits the search scope and helps the query engine select the correct index.

  3. Update existing indexes to cover additional properties if your query has evolved.

  4. Use efficient node types: prefer oak:Unstructured over nt:unstructured and sling:Folder over sling:OrderedFolder when ordering is not required.

  5. Consider architectural changes: if queries consistently hit the limit, the repository structure may need reorganization.

Development Workaround

During development only, you can temporarily increase the read limits:

  1. Navigate to QueryEngineSettings in the JMX console:
1
http://localhost:4502/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3Dsettings%2Ctype%3DQueryEngineSettings
  1. Increase the LimitReads and LimitInMemory parameters.

Warning: This is a development-only workaround. Never deploy increased limits to production, as it masks underlying performance problems and can cause system instability.

Further Reading

For a comprehensive guide to JCR-SQL2 query syntax, indexing strategies, and debugging techniques, see the JCR-SQL2 Query with Examples post.

Contents