Fixing SegmentNotFoundException issue:
In this blog I am going to explain how we can fix the repository inconsistencies. When the repository corrupts due to inconsistencies in the repository, the server itself start properly.
In this blog I am going to explain how we can fix the repository inconsistencies. When the repository corrupts due to inconsistencies in the repository, the server itself start properly.
Whenever we see an exception like below in the error log, we need to revert back the oak repository to good revision of a segment store.
Exception in thread "main" org.apache.jackrabbit.oak.plugins.segment.SegmentNotFoundException: Segment a7aecb54-aec0-4bec-a3cc-0721b81a60b0 not found
To fix the above problem we need to run the oak utility to find the last latest good revision change into Oak's working directory (the one containing the crx-quickstart folder). Please follow the below steps to fix the issue.
- Run the consistency check,
java -jar oak-run.jar check -d1 --bin=-1 -p /<aem-install-dir>/crx-quickstart/repository/segmentstore/
- It will search backwards through the revisions until it finds a consistent one:
14:00:30.783 [main] INFO o.a.j.o.p.s.f.t.ConsistencyChecker - Found latest good revision afdb922d-ba53-4a1b-aa1b-1cb044b535cf:234880
16:52:16.937 [main] DEBUG o.a.j.o.p.s.f.t.ConsistencyChecker - Checking /apps/psw/www-perceptivesoftware-com/install/psw.com-services-1.0.0.0.1-SNAPSHOT.jar/jcr:content/jcr:uuid = bd9c3908-4f27-4d64-becf-b12b15792da7
16:52:17.050 [main] INFO o.a.j.o.p.s.f.t.ConsistencyChecker - Traversed 35427133 nodes and 40187798 properties
16:52:17.050 [main] INFO o.a.j.o.p.s.f.t.ConsistencyChecker - Found latest good revision dc9944de-71bd-4804-a494-9b277bcac833:261784
16:52:17.050 [main] INFO o.a.j.o.p.s.f.t.ConsistencyChecker - Searched through 462 revisions
- Revert the repository to this revision by editing
./crx-quickstart/repository/segmentstore/journal.log
- Delete all lines after the line containing the latest good revision from journal.log
- Remove all ./crx-quickstart/repository/segmentstore/*.bak files.
- Run checkpoint clean-up to remove orphaned checkpoints:
java -jar oak-run-*.jar checkpoints ./crx-quickstart/repository/segmentstore rm-unreferenced
- Finally compact the repository:
java -jar oak-run-*.jar compact ./crx-quickstart/repository/segmentstore/
MORE INFORMATION ABOUT OAK TOOL CAN BE FOUND HERE:
Warning: When we run this consistency check, due to the nature of this function the latest changes will lost and reverts to the last good revision available in journey.log.