Lucene index corrupted on Primary author

Environment

AEM 6.2 SP1 CFP18

Issue

Lucene index is sometimes corrupted on Primary author instance, slowing down the performance of the instance.
In the log file, the following trace can be seen:

*WARN* [aysnc-index-update-async] org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorContext could not update suggester
java.io.IOException: Invalid byte range request for [/oak:index/damAssetLucene][_4vn.fnm], position: 0, file length: 0, len: 1
at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexFile.readBytes(OakDirectory.java:474)
at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexInput.readBytes(OakDirectory.java:600)
at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexInput.readByte(OakDirectory.java:607)
at org.apache.lucene.store.DataInput.readInt(DataInput.java:84)
at org.apache.lucene.codecs.CodecUtil.checkHeader(CodecUtil.java:126)
at org.apache.lucene.codecs.lucene46.Lucene46FieldInfosReader.read(Lucene46FieldInfosReader.java:56)

Impact

Corruption of the lucene index and degradation of the performance of the author

Solution

The above error message points out to directory lookup not being closed. 
This issue is related to https://issues.apache.org/jira/browse/OAK-6895 which has been solved in Oak 1.4.24 through internal reference NPR-26565

In order to solve this issue, the steps are:

  • Upgrade to Oak 1.4.24+
  • Refresh the index cache in crx-quickstart/repository/index
  • Monitor the instance to ensure that the issue doesn't appear again