Skip to content

Instantly share code, notes, and snippets.

@andrewmkhoury
andrewmkhoury / Oak Datastore Check.md
Last active April 29, 2021 08:19
Oak Datastore Consistency Check
  1. Download the oak-run version that matches what is installed from http://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/
  2. Stop all AEM instances in cluster
  3. Upload the oak-run jar to the AEM server
  4. Run this command to start the oak console
  • on TarMK:
   java -Xmx4g -jar target/oak-run.jar console --quiet /path/to/segmentstore
  • For MongoMK run this:
@andrewmkhoury
andrewmkhoury / Dump datastore references.md
Last active April 29, 2021 08:19
How to dump the list of datastore references in Oak``
  1. Download oak-run version matching the version of oak-core you have and upload it to the server: wget http://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/

  2. Run this command to extract the list of datastore files from the segmentstore:

    java -Xmx6g -jar oak-run-*.jar dumpdatastorerefs [<segment_path>|<mongo_uri>] [dump_path]

    e.g. TarMK java -Xmx6g -jar oak-run-*.jar dumpdatastorerefs crx-quickstart/repository/segmentstore .

If you find an error like this one in the logs (more of an example error below [1]) you may have a corrupt Oak revision:

Caused by: org.apache.jackrabbit.oak.plugins.document.DocumentStoreException: The node 4:/oak:index/event.job.topic/:index/replication was already added in revision
r14e64620028-0-1, before
r14e6463b2c0-0-1; document:
{_lastRev={r0-0-1=r14e64620028-0-1},
_deletedOnce=true,

To verify whether or not it is real corruption, do the following then save the format-revision.html to your system and open it in a browser. Paste the two revisions into the corresponding text fields. You will get output like this:

Clean up sling jobs at the mongodb level in AEM6.0

  1. Log into mongo shell on the primary mongo node
  2. Download oak-mongo.js to the server
wget http://s.apache.org/oak-mongo.js
  1. Run this on the command line

Note that offline compaction requires a long duration of downtime from 30 minutes to 7 hours (and in extreme cases more time).

Offline Oak compaction with debug logging:

  1. Stop Oak / AEM
  2. Install the latest Oak hotfix to your AEM instance:
@andrewmkhoury
andrewmkhoury / ClonedReindexingInstructions.md
Last active April 29, 2021 08:20
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)
@andrewmkhoury
andrewmkhoury / INSTRUCTIONS.md
Last active July 15, 2019 12:33
Apache Sling - enabling debug log level for all java packages when instance won't start up
  1. Open this file in an editor crx-quickstart/launchpad/config/org/apache/sling/commons/log/LogManager.config
  2. Change org.apache.sling.commons.log.level value from "info" to "debug"
  3. Try to start the instance again

AEM6.x Migration

  • How to Rebuild a Pre-Existing AEM+Mongo Cluster
  • or migrate from Tar to MongoDB or MongoDB to Tar"
  • or migrate from 5.6.1 or 6.x to 6.x via data migration instead of jar upgrade
  1. (Mongo to Mongo only) Remove one replica from the replica set and delete/recreate the db
    1. Remove the replica node from the set: http://docs.mongodb.org/master/tutorial/remove-replica-set-member/
    2. Validate that no other nodes in the set consider that node to be part of the set anymore. Log into each node in the cluster via mongo shell and run rs.status() to validate that the node that was taken out is not in the cluster any longer.
    3. Drop the aem database on that node http://docs.mongodb.org/manual/reference/command/dropDatabase/
  2. Re-add the database with the correct user permissions (do not add the mongo instance back to the replica set)
@andrewmkhoury
andrewmkhoury / OakMaintenanceLogMessages.md
Last active August 29, 2017 21:22
Apache Oak Maintenance Log Messages

MongoDB Storage (aka "MongoMK") and RDBMK:

Revision GC:

12.09.2015 00:00:00.857 *INFO* [pool-7-thread-10] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Starting revision garbage collection. Revisions older than [2015-09-11 00:00:00.857] would be removed
13.09.2015 00:00:15.912 *INFO* [pool-7-thread-9] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Iterated through 10000 documents so far. 9698 found to be deleted
14.09.2015 00:00:49.358 *INFO* [pool-7-thread-12] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Deleted 859050 (58.28%) documents so far
12.09.2015 00:39:43.490 *INFO* [pool-7-thread-10] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Version garbage collected in 39.71 min. VersionGCStats{ignoredGCDueToCheckPoint=false, deletedDocGCCount=180021, splitDocGCCount=4853, intermediateSplitDocGCCount=441, timeToCollectDeletedDocs=14.62 min, timeTakenToDeleteDocs=23.52 min}
@andrewmkhoury
andrewmkhoury / README.md
Last active May 10, 2018 20:50
How to use oak-mongo.js to delete an index
  1. Stop all Oak cluster nodes (or AEM6 cluster nodes)
  2. On the mongo server, run these commands to log in to mongo shell with oak-mongo.js loaded wget http://svn.apache.org/repos/asf/jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js mongo 127.0.0.1/aem-author --shell oak-mongo.js
  3. In the mongo shell run this command to get a list of all index names oak.listChildren("/oak:index")