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

Exception is thrown when UserGroup count is over Elasticsearch's 'index.max_result_window' setting

    Details

    • Story Points:
      1
    • Fix Priority:
      4

      Description

      Workaround Increase "'index.max_result_window" to a higher value through either

      Steps to Reproduce:

      1. Go to Control Panel > Configuration > Server Administration > Script. Paste and execute this groovy script to create 10K User Groups. (It took about 7 min for the user groups to be created)
        import com.liferay.portal.kernel.model.User;
        import com.liferay.portal.kernel.service.UserGroupLocalServiceUtil;
        import com.liferay.portal.kernel.service.ServiceContext;
        import com.liferay.portal.kernel.service.ServiceContextFactory;
        import com.liferay.portal.kernel.service.UserLocalServiceUtil;
        import com.liferay.portal.kernel.util.StringPool;
        
        int numUserGroups = 10001;
        
        String userGroupName = "Test User Group ";
        
        try {
        	ServiceContext serviceContext = ServiceContextFactory.getInstance(
        			actionRequest);
        
        	long userId = serviceContext.getUserId();
        
        	User user = UserLocalServiceUtil.getUser(userId);
        
        	long companyId = user.getCompanyId();
        
        	for (int i = 1; i <= numUserGroups; i++) {
        		String name = userGroupName + i;
        
        		UserGroupLocalServiceUtil.addUserGroup(
        				userId, companyId, name, StringPool.BLANK, serviceContext);
        
        		if (i % 100 == 0) {
        			System.out.println("Created " + i + " User Groups");
        		}
        	}
        }
        catch (Exception e) {
        	println("Exception Thrown: " + e);
        }
        
      2. Go to Control Panel > Configuration > System Setting > Foundation > Elasticsearch. Uncheck "Log exceptions only" and Save.
      3. Go to Control Panel > Users > User Groups
      4. (After LPS-72199 is fixed) Click on page 501 of the search container

      Expected Result:
      User Groups would be shown with no error.

      Actual Result:
      No User Groups are shown and an exception is thrown in the logs:

      18:35:57,673 ERROR [http-nio-8080-exec-8][IncludeTag:128] Current URL /group/control_panel/manage?p_p_id=com_liferay_user_groups_admin_web_portlet_UserGroupsAdminPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_com_liferay_user_groups_admin_web_portlet_UserGroupsAdminPortlet_delta=20&_com_liferay_user_groups_admin_web_portlet_UserGroupsAdminPortlet_orderByCol=name&_com_liferay_user_groups_admin_web_portlet_UserGroupsAdminPortlet_orderByType=asc&_com_liferay_user_groups_admin_web_portlet_UserGroupsAdminPortlet_resetCur=false&_com_liferay_user_groups_admin_web_portlet_UserGroupsAdminPortlet_cur=501 generates exception: com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.search.SearchException: all shards failed
      QueryPhaseExecutionException[Result window is too large, from + size must be less than or equal to: [10000] but was [10020]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter.]
      	at org.elasticsearch.search.internal.DefaultSearchContext.preProcess(DefaultSearchContext.java:200)
      	at org.elasticsearch.search.query.QueryPhase.preProcess(QueryPhase.java:103)
      	at org.elasticsearch.search.SearchService.createContext(SearchService.java:674)
      	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:618)
      	at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:461)
      	at com.liferay.portal.search.elasticsearch.internal.connection.EmbeddedElasticsearchConnection.lambda$createNode$0(EmbeddedElasticsearchConnection.java:338)
      	at org.elasticsearch.transport.TransportService.sendLocalRequest(TransportService.java:344)
      	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:310)
      	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:282)
      	at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteFetch(SearchServiceTransportAction.java:169)
      	at org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryAndFetchAction.java:74)
      	at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:166)
      	at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.start(TransportSearchTypeAction.java:148)
      	at org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction.doExecute(TransportSearchQueryAndFetchAction.java:58)
      	at org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction.doExecute(TransportSearchQueryAndFetchAction.java:47)
      	at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:70)
      	at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:103)
      	at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:44)
      	at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:70)
      	at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:58)
      

      Testing:
      Reproduced in 7.0.x - bd606dc002774835d7e3688912e73e1a76948ca6
      Reproduced in master - e567dd03399c2c6c1b042345d122589367ea16c2

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

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

                  Packages

                  Version Package