How to reindex a synchronous AEM index | AEM, Oak

Objective

How do I properly reindex a synchronous Oak index without causing downtime?

Steps

Reindexing a synchronous index by simply setting reindex property to true results in a synchronous operation which can cause an Oak instance to hang. To avoid this situation send indexing to a background thread. To do this, follow the steps below:

Reindex in a background thread

Set the following properties from CRXDE Lite on the index definition for the property index to be enabled for async indexing - /oak:index/<property index>
reindex=true

reindex-async=true

To validate that the above refresh the node, async="async-reindex" should be set.

Invoke the startPropertyIndexAsyncReindex on the PropertyIndexAsyncReindex MBean. This would start the background job which would search for such types of indexes. Post invocation you should see a log line Reindexing will be performed ...

Once the re-indexing is complete reindex flag would be reset to false.

Re-invoke step 3 to change back the index to a sync index. If async flag is not deleted then the Mbean may have to be invoked multiple times (This may happen if there are changes happening concurrently affecting this index).

Note: Only the 'async="async-reindex"' will be removed as that controls which thread the indexing will happen on. The 'reindex-async' property is just a configuration flag which will not change automatically. The idea is that you'd set it once for the specific index definitions controlling all future reindexing. That is then expected that it stay in there and then you won't need to touch it again.

Remove the reindexing checkpoint (AEM 6.2 and older versions only)

During the process of async reindexing, a repository checkpoint is created. Once the indexing task has completed, it must be released as described below, to ensure smooth Revision Garbage Collection later on :