Some services are indexing more than once the same object in the same transaction, just because they call to other methods that indexing the same object again, this should be avoided and only indexing the object at the end of the transaction.
For example, in JournalArticle index operation, there are 4 request to indexer.reindex()
- Three updates with status=draft (the three request are done in different points of JournalArticleLocalServiceImpl and AssetEntry framework)
- A last update with status=published (this last update is done in updateStatus call, that is done at the end)
As write to index is an asynchronous process, Indexing a object more than once can cause race condition problems in case of having first indexation request to be executed the last.
Steps to reproduce:
- Activate debug traces for com.liferay.portal.search.lucene.LuceneIndexWriter
- Create a new webcontent and save it
- Check log for DefaultIndexerRequestBufferExecutor traces:
- Expected behavior: only index request is executed and there are no duplicated indexation lines
- Wrong behavior: 4 or 5 index request are executed and there are duplicated indexation lines
Important: check only lines with 15_PORTLET fragment. Other lines with 19_PORTLET and similar doesn't belong to updated JournalArticle
Note: Index Buffer is enabled by default since Liferay 6.2 fixpack 134. If you want to disable it, in 6.2 version you can deactivate it adding following property to portal-ext.properties file: