Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-47032

Objects should not be indexed more than once in the same transaction

Details

    Description

      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.

      As developer I need a mechanism to register an indexing callback for one object, and all the services should use it. This mechanism should avoid register duplicate indexing callbacks because only one will be needed when the transaction ends.

      Examples of multiple indexing:

      CASE 1: com.liferay.portal.service.impl.UserLocalServiceImpl.addUserWithWorkflow(...)

      This method register a callback to perform the user indexing, however, the user is being indexing internally in the same method while add permissions to the user calling resourceLocalService.addResources, which finally ends executing SearchEngineUtil.updatePermissionFields(name, primKey) in where the object is indexed.

      CASE 2: com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.addPage(...)

      This method runs the indexing by call to
      com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.addPageResources(...)

      and by call to:
      com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.startWorkflowInstance(...)
      -> com.liferay.portlet.wiki.workflow.WikiPageWorkflowHandler.updateStatus(...)
      -> com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.updateStatus(...)
      -> indexer.reindex(page)

      CASE 3: uses of @Indexable(type = IndexableType.REINDEX) in concatenated methods

      eg:
      https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/journal/service/impl/JournalArticleLocalServiceImpl.java#L1314

      https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/journal/service/impl/JournalArticleLocalServiceImpl.java#L5243

      Updated: current code of JournalArticleLocalServiceImpl.updateArticle() indexes 4 times the same version because now AssetEntryLocalServiceImpl.updateEntry is also reindexing the article.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jose.jimenez Jose Jimenez
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Packages

                  Version Package