How to reindex a synchronous AEM index | AEM, Oak

To reindex an synchronous AEM index, you could simply set the reindex property to true. However, this may cause an Oak instance to hang in which case you need to send the indexing to a background thread. This article explains how.

Description description

Environment

Adobe Experience Manager

Issue/Symptoms

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

Resolution resolution

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. Follow the steps below:

Step 1: Reindex in a background thread

  1. Set the following properties from CRXDE Lite on the index definition for the property index to be enabled for async indexing:

    code language-none
    /oak:index/<property index>
    reindex=true
    reindex-async=true
    
  2. To validate that the above refresh the node, async="async-reindex" should be set.

  3. 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…

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

  5. 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.

Step 2: 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:

  1. First, open the CheckpointManager MBean:

    On MongoMK - /system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DDocument+node+store+checkpoint+management%2Ctype%3DCheckpointManger

    On TarMK - /system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DSegment+node+store+checkpoint+management%2Ctype%3DCheckpointManger

  2. Invoke the listCheckpoints() operation.

  3. Find the checkpoint row with the name=async-reindex property.

  4. Copy its id value to the clipboard:

    On MongoMK, it will look similar to this: r1234567aaaa-0-1

    On TarMK, it will look similar to this: 6eac07d0-fe27-4d16-82f8-6d5da4cefd67

  5. Then open the releaseCheckpoint() operation.

  6. Paste the copied id as p1 and click Invoke.

  7. This step will release the checkpoint.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f