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

Import of large amounts of pages and fragments fails with "duplicated entry error"

    Details

      Description

       Reproduction steps

      This problem is reproducible when importing a large .lar file which includes a lot of Layouts referencing LayoutPageTemplateStructures. Therefore the attached (and adapted) customer's .lar files should be used to get the errors in master:

      1. Import, from Control Panel - Configuration - Custom Fields - Import/Export, custom_fields.lar
      2. Import, from Global site's Publishing - Import option, Global.lar (ignore all journal article's template related exceptions that may be thrown).
      3. Create a blank site and import new_site.lar file

      Expected result: the new site .lar gets imported without problems. 

      Current result: duplicated entries for index IX_87B60D9 errors are thrown and the process fails with an exception (see attached full_log_error.txt):

       

      ERROR [liferay/background_task-2][JDBCExceptionReporter:234] Duplicate entry '57429-20002-23' for key 'IX_87B60D9'

       

      Analysis

      The following is the workflow of a Layout import process*:*

      1.  A Layout with a LayoutPageTemplateStructure ** reference is to be imported. 
        1. The imported layout is generated with a new plid and imported.].
        2. Layout's references are imported, in this case we will focus on the LayoutPageTemplateStructure ** ones. For each one:
          1. If any with the same (uuid, groupid) exists, it is added to the database with its original classPK (the one indicated in its corresponding xml).
          2. After being persisted, the entry is updated changing its classPK (to the Layout.plid) and classnameId.

      Problems
      Having a large number of Layouts and LayoutPageTemplateStructures, we may get a 'Duplicate Entry' error in step 2.1:

      • LayoutPageTemplateStructure table contains, a unique index named IX_87B60D9 consisting on (groupid, classnameid, classPK).
      • In step 2.2 entries are assigned with a new classPK which does not have into account point 2.1, where entries and their 'old' classPKs are initially imported. that may conflict.

       

      Example

      In manifest.xml of the explorted .lar (fagor) we find, for example a Layout (96.xml) referencing a LayoutPageTemplateStructure:

       

        <staged-model group-id="20123" uuid="4294a71c-d22a-6431-c30e-9fbf8ffab6fa" layout-uuid="4294a71c-d22a-6431-c30e-9fbf8ffab6fa" layout-id="68"         layout-parent-layout-id="7" layout-priority="2147483647" action="add" parent-layout-uuid="3fb593d7-b5c3-7e43-550f-79340ac32b1e"                   path="/group/20123/com.liferay.portal.kernel.model.Layout/96.xml"{...}>
      <references>
      {...}
          <reference class-name="com.liferay.layout.page.template.model.LayoutPageTemplateStructure" class-pk="63130" attached-class-                     name="com.liferay.portal.kernel.model.Layout" group-id="20123" group-key="Guest" live-group-id="20123" type="dependency" 
           uuid="6680392c-  e649-5a5a-8b2b-cb1097eddb78" company-id="20101" missing="false"/>
       </references>
      </staged-model>
      

      We also find the referenced LayoutPageTemplateStructure staged-model :

       

      <staged-model uuid="6680392c-e649-5a5a-8b2b-cb1097eddb78" group-id="20123"  path="/company/20101/com.liferay.layout.page.template.model.LayoutPageTemplateStructure/63130.xml" attached-class- name="com.liferay.portal.kernel.model.Layout" user-uuid="d0c165ba-4907-2f53-b1a9-3bcbbbf1bb3b" asset-entry-priority="0.0"> 
      
        <references> 
          <reference class-name="com.liferay.layout.page.template.model.LayoutPageTemplateStructureRel" class-pk="63131" group-id="20123" group- key="Guest" live-group-id="20123" type="child" uuid="c36ad419-a7d0-374d-5d03-1e18db8eba63" company-id="20101" missing="false"/> 
        </references> 
      </staged-model>

      63130.xml shows the LayoutPageTemplateStructure has classPk = 96. According to step 2.1 the following data will be imported:

       

      uuid        -> 6680392c-e649-5a5a-8b2b-cb1097eddb78
      groupId     -> 60449
      classnameid -> 20002
      classPk     -> 96 (original)
      

      However we can see the next error in the log:

      ERROR [liferay/background_task-1][JDBCExceptionReporter:234] Duplicate entry '60449-20002-96' for key 'IX_87B60D9'

       

      Because there is already one entry (see data below)in LayoutPageTemplateStructure table which was previously imported and makes the new one duplicate the index:

       uuid        -> 8c7d8dd7-b8b2-69d3-3bbf-528a2816904f
      groupId     -> 60449
      classnameid -> 20002
      classPk     -> 96
      
      

       Which we can find also in the manifest.xml (by its uuid) and see its original classPK was 23, but then updated to 96 in step 2.2.

       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 weeks, 2 days ago

                  Packages

                  Version Package
                  7.2.X
                  7.2.1 CE GA2
                  Master