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

Create large number of users through Liferay API we get an error saying "Too many open files"


    • Type: Bug
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s: 6.0.6 GA
    • Fix Version/s: 6.0.6 GA
    • Labels:
    • Environment:
      Linux and windows


      Whenever a user is created or associated to a user-group some zip files are created in liferay tomcat temp folder . The files correspond to the public private pages of the group associated . If user created are very large server crashes saying "Too many open files".

      The zip files are created when we call adduser method of UserService.
      The add user internally calls addUserGroupUsers which leads to file creation
      1. UserLocalServiceUtil.addUserGroupUsers(userGroupId, userIds); //UserInfoLocalServiceImpl in addUsersUserGroups() method
      2. userGroupLocalService.copyUserGroupLayouts(userGroupId, userIds); //UserLocalServiceImpl.java-> addUserGroupUsers() method
      3. files = exportLayouts(userGroupId, parameterMap); //UserGroupLocalServiceImpl.java-> copyUserGroupLayouts() method

      //Code that exports layouts to zip file in UserGroupLocalServiceImpl.java
      files[0] = layoutLocalService.exportLayoutsAsFile(groupId, true, null, parameterMap, null, null);
      files[1] = layoutLocalService.exportLayoutsAsFile(groupId, false, null, parameterMap, null, null);
      return files;

      In layout exporter the file are created by usingexportLayoutsAsFile() method mentioned above .
      //Layout exporter
      zipWriter = ZipWriterFactoryUtil.getZipWriter();//LayoutExporter.class -> exportLayoutsAsFile() method
      PortletDataContext context = new PortletDataContextImpl(companyId, groupId, parameterMap, new HashSet(), startDate, endDate, zipWriter);

      If we try to bypass the zip file creation the files[0] and files[1] then files are not created but when user logs in the portal it gets default liferay pages not the group public, private pages . My initial thought was that the server looks for the temp folder zip files only if its newly created (connection to file open) otherwise it will refer database so I created another user but before logging in I restarted the server . Group -pages were still not reflected even though the user has mapping to the user-group in database .
      Are these zip files in temp are mandatory for first time logging??
      I also tried to delete the temp files every 1 minute via an batch process, but though the zip file is getting deleted, the file handle still remains open. The file handle for all these zip files are created by the main liferay process and only server restart kills the file handler

      I did some analysis and found that the files are created/not-created in following cases
      1. When user is associated with a group that has different template of public private page. 2 zip files are created.
      2. When user is created and not associated to any user-group .As only association of user group created the zip. No zip file is created
      3. When user is associated to a user group with no public private pages ,that is an empty group .
      4. When the group has same template for public private pages . one zip file is created as each zip file correspond to user pages.
      5. When user group is altered in a way that portlets on public private pages are changed or an empty group is assigned some template zip is created for the group not the user


          Issue Links



              mika.koivisto Mika Koivisto (Inactive)
              arjunmullick Arjun Mullick (Inactive)
              Participants of an Issue:
              Recent user:
              Esther Sanz
              0 Vote for this issue
              1 Start watching this issue


                Days since last comment:
                9 years, 21 weeks, 2 days ago


                  Version Package
                  6.0.6 GA