Skip to content

Instantly share code, notes, and snippets.

@andrewmkhoury
Last active April 29, 2021 08:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save andrewmkhoury/08bfbbdbe4dd4e6dc4dd to your computer and use it in GitHub Desktop.
Save andrewmkhoury/08bfbbdbe4dd4e6dc4dd to your computer and use it in GitHub Desktop.
Reindexing Oak Async Indexes on a Clone AEM Instance

How to Reindex AEM on a Clone Instance and Sync over the Changes

  1. Clone your AEM instance to another VM for reindexing
  2. Download these oak-run jars:
  1. Upload the oak-run jars to the clone server
  2. Stop AEM (stop all AEM instances if a cluster or cold standby)
  3. Run this command (using oak-run-1.6.6.jar)
  • java -Xmx4096m -jar oak-run-1.6.6.jar checkpoints /path/to/repository/segmentstore
  1. Run this command (using oak-run-1.6.6.jar)
  • java -Xmx4096m -jar oak-run-1.0.23.jar checkpoints /path/to/repository/segmentstore rm-all
  1. Run this command to perform offline compaction (using oak-run-1.6.6.jar)
  • nohup java -Dtar.memoryMapped=true -Dupdate.limit=5000000 -Dcompaction-progress-log=1500000 -Dcompress-interval=10000000 -Doffline-compaction=true -Xmx10g -jar oak-run-1.6.6.jar compact crx-quickstart/repository/segmentstore > tarcompaction.log 2>&1 &
  1. Start AEM (on startup all OOTB async indexes would be recreated from scratch and fully indexed)
  2. Monitor the indexing process by looking for log messages like these.

These show that the indexing started:

17.11.2015 16:22:18.481 *INFO* [FelixStartLevel] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing would be performed for following indexes [/oak:index/cqCloudServiceConfig, /oak:index/slingeventEventId, /oak:index/cqPayloadPath]
17.11.2015 16:22:26.624 *INFO* [pool-70-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing would be performed for following indexes [/oak:index/damFileSize, /oak:index/cqLastModified]
17.11.2015 16:30:38.060 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Found a new index node [damFileSize]. Reindexing would be requested
17.11.2015 16:30:38.074 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Found a new index node [cqLastModified]. Reindexing would be requested
17.11.2015 16:30:38.074 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing would be performed for following indexes [/oak:index/damFileSize, /oak:index/lucene, /oak:index/cqLastModified]

These messages show indexing progress:

17.11.2015 16:31:04.293 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #220000 /libs/granite/i18n/pt-br/Last build_
17.11.2015 16:31:05.603 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing Traversed #230000 /libs/granite/security/content/groupEditor/items/page/items

If you see this log message then it completed successfully:

17.11.2015 16:31:08.294 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate Reindexing (async) completed for indexes: [/oak:index
/damFileSize*(93), /oak:index/lucene*(237527), /oak:index/cqLastModified*(1525)] in 30.24 s

If you never saw a "completed" log message and this log message shows up again (or similar "Reindexing would be ..." message) then it means indexing failed and has gone in a loop:

17.11.2015 16:30:38.074 *INFO* [pool-9-thread-5] org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing would be performed for following indexes [/oak:index/damFileSize, /oak:index/lucene, /oak:index/cqLastModified]

If it failed then go to /system/console/slinglog UI and enable Debug level logging for org.apache.jackrabbit.oak.plugins.index. The next time the indexing loops (showing "Reindexing would be performed" you would see a log message before the error showing an error indicating why indexing failed. Contact Adobe AEM Customer Care and provide them that log file. 15. Copy over changes that occurred on the production instance during the reindexing on the copy

  1. Install this tool to the production live (source) instance:
    http://adobe-consulting-services.github.io/acs-aem-commons/features/query-packager.html
  2. Create package using a search for pages that changed since the copy was done. Use this query for pages (but change the date):
    • //element(*,cq:PageContent)[@cq:lastModified >= xs:dateTime('2015-09-16T00:00:00.000-05:00')]
  3. Create package using a search for assets that changed since the copy was done. Use this query for assets (but change the date):
    • //element(*, dam:AssetContent)[@jcr:lastModified > xs:dateTime('2015-09-16T00:00:00.000-05:00')]
  4. Create package using a search for tags that changed since the copy was done. Use this query for tags (but change the date):
    • //element(*, cq:Tag)[@jcr:created > xs:dateTime('2015-09-16T00:00:00.000-05:00')]
  5. Install all the packages to the (clone) AEM instance (install the tags first, then the assets then pages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment