Adobe-Consulting-Services / acs-aem-tools

http://adobe-consulting-services.github.io/acs-aem-tools/
120 stars 97 forks source link

Ensure OAK Index not firing forceRefresh when recreateOnUpdate is set to true #201

Closed alok-sharma-acs closed 5 years ago

alok-sharma-acs commented 6 years ago

We have had instances where the category landing pages (gets list of articles based on a search query that utilizes a custom index created using Ensure Oak service) start coming as empty and do not show any articles at all. This means at that time there is no way users can access articles on the website.The way we currently fix this is to reindex the custom index and clear dispatcher cache (as category landing pages are cached).I tried to do a RCA for that and have found the below.The problem occurs when we do a deployment of custom code containing the custom oak index definitions. My idea is that the deployment causes the Ensure Oak service to get triggered and as the Immediate flag is set it processes the custom indexes.The custom indexes have the property recreateOnUpdate set to true. This causes the existing index definition to be deleted and recreated.When I checked the code I realized that in this case the indexes are recreated but the force index is not triggered. Code Snapshot: At EnsureOakIndexJobHandler.ensure()handleHeavyWeightIndexOperations() method is called As recreateOnUpdate is set to true it calls delete(oakIndex); followed by create(ensureDefinition, oakIndexes); but does not make a call to forceRefresh(oakIndex); Can you please validate and let us know if this is a product issue and if there is any hotfix available for this (if this is a known issue).

davidjgonzalez commented 6 years ago

Creating a new Lucene index will cause it to be reindexed on the next async reindex by oak automatically. No need to call force refresh.

1) are you changing the ensure oak index definition with this code deploy? If not, then any aem instance w this index already deployed should not do ANY reindexing.

2) if you are changing the index definition, why are you recreating on update? Recreating means no data will be available In the index until reindexing completes.

Generally if you are deploying indexes you either want to 1) set forceIndex to true, which sets redindex=true if there is a delta between the existing oak index and the ensure index definition OR leave forceIndex off (aka false) and manually trigger reindexing via the Felix ensure oak index web console / the ensure index jmx mbean

The key in all this is you want to trigger reindexing ONLY when you have a material change to an index. Reindexing should be avoided as much as possible.

davidjgonzalez commented 5 years ago

Closing due to inactivity