Julian Reschke created SLING-13387:
--------------------------------------

             Summary: Paged query for aliases fails due to stale alias index 
and shifting sling:alias values
                 Key: SLING-13387
                 URL: https://issues.apache.org/jira/browse/SLING-13387
             Project: Sling
          Issue Type: Bug
          Components: ResourceResolver
            Reporter: Julian Reschke
            Assignee: Julian Reschke


(AI generated summary) 

Alias resolution and querying rely heavily on the resource resolver's alias 
index (Oak property/traversal index tracking {{{}sling:alias{}}}).

When executing *paged queries* for aliases across a large content tree, 
pagination relies on consistent sorting or offset keys. However, if the alias 
index is stale or if the underlying "first" values of multi-valued or 
dynamically changing {{sling:alias}} properties shift unexpectedly between page 
fetches, the pagination mechanism breaks. This results in failed queries, 
missing results, or inconsistent data sets being returned.
h3. Steps to Reproduce
 # Set up an environment with a significant volume of resources containing 
{{sling:alias}} properties.

 # Trigger a background content update or frequent creations/modifications that 
actively alter {{sling:alias}} values.

 # Execute a *paged query* (using limit/offset or cursor-based pagination) 
targeting the alias index.

 # Observe the query execution while the index is catching up or when the 
sorting key ({{{}sling:alias{}}} first value) mutates between pages.

h3. Actual Behavior
 * Paged queries fail with query execution exceptions, or return 
truncated/duplicated results.

 * The Oak index logs warnings or errors regarding traversal/staleness.

 * Pagination cursors become invalid because the underlying index order shifted 
mid-pagination due to changing property values.

h3. Expected Behavior
 * Paged alias queries should remain resilient against minor index staleness or 
handle shifting property values gracefully.

 * Robust error handling or alternative fallback sorting mechanisms should 
prevent total query failures when index states are inconsistent.

h3. Technical Notes / Root Cause
 * *Index Staleness:* Oak async indexes take time to re-index, leading to a 
window where queries return stale or shifting pointers.

 * *Unstable Sorting Keys:* Multi-valued {{sling:alias}} properties or frequent 
updates change the lexical "first" value used for ordering, breaking standard 
offset/limit pagination assumptions.

 * *Possible Mitigations:* Investigate implementing deterministic sorting 
(e.g., combining with jcr:uuid or path as a secondary sort criterion) or 
improving index configuration parameters for {{{}sling:alias{}}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to