Uploaded image for project: 'JBoss BPMS Platform'
  1. JBoss BPMS Platform
  2. RHBPMS-5091

Pagination displays incorrect amount of tasks when custom advanced query returns duplicate records in BPM Suite 6.4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.4.9
    • 6.4.6
    • Kie-Server
    • CR1
    • Hide

      1. Created the process definition with only an User Task and assigned to groups for it "manager, developer";
      2. Make sure to have an user in kie-server (i.e. brmsuser) which is assigned to both groups;
      3. After build&deploying the project in kie-server start two processes instances. Deploy the kjar containing the process to a kie server instance using a prod database, like mysql;
      4. Register the query mentioned in case description using the advanced query API. Here's a hand curl:

      curl -X POST -u 'kieserver:kieserver1!' \
          --data "<query-definition><query-name>getAllTasks</query-name><query-source>java:jboss/datasources/MySQLDS</query-source><query-expression>SELECT ti.*, oe.id as oeid FROM AuditTaskImpl ti, PeopleAssignments_PotOwners po, OrganizationalEntity oe WHERE ti.taskId= po.task_id AND po.entity_id = oe.id</query-expression><query-target>PO_TASK</query-target></query-definition>"  \
          -H 'Content-type: application/xml' \
          'http://localhost:8180/kie-server/services/rest/server/queries/definitions/reproducer'
      

      5. Start two process instances;
      6. Run the query above directly in the database - it should return 4 records - it is expected, 2 records per process instance;
      7. Next, let's run it with the advanced query by using kie-server rest endpoint:

       curl -u 'kieserver:kieserver1!' 'http://localhost:8180/kie-server/services/rest/server/queries/definitions/reproducer/data?mapper=UserTasksWithCustomVariables&pageSize=2&page=0'
      

      8. The issue is now: add paging parameters you will see that it will return only 1 result in page=0, the other result is returned in page=1. If we set the pageSize to 4 and page=0, it returns two results.

      Since it should return only two tasks, it should display all results in page=0 if pageSize=2. It seems to be an internal bug on pagination.

      Show
      1. Created the process definition with only an User Task and assigned to groups for it "manager, developer"; 2. Make sure to have an user in kie-server (i.e. brmsuser) which is assigned to both groups; 3. After build&deploying the project in kie-server start two processes instances. Deploy the kjar containing the process to a kie server instance using a prod database, like mysql; 4. Register the query mentioned in case description using the advanced query API. Here's a hand curl: curl -X POST -u 'kieserver:kieserver1!' \ --data "<query-definition><query-name>getAllTasks</query-name><query-source>java:jboss/datasources/MySQLDS</query-source><query-expression>SELECT ti.*, oe.id as oeid FROM AuditTaskImpl ti, PeopleAssignments_PotOwners po, OrganizationalEntity oe WHERE ti.taskId= po.task_id AND po.entity_id = oe.id</query-expression><query-target>PO_TASK</query-target></query-definition>" \ -H 'Content-type: application/xml' \ 'http: //localhost:8180/kie-server/services/ rest /server/queries/definitions/reproducer' 5. Start two process instances; 6. Run the query above directly in the database - it should return 4 records - it is expected, 2 records per process instance; 7. Next, let's run it with the advanced query by using kie-server rest endpoint: curl -u 'kieserver:kieserver1!' 'http: //localhost:8180/kie-server/services/ rest /server/queries/definitions/reproducer/data?mapper=UserTasksWithCustomVariables&pageSize=2&page=0' 8. The issue is now: add paging parameters you will see that it will return only 1 result in page=0, the other result is returned in page=1. If we set the pageSize to 4 and page=0, it returns two results. Since it should return only two tasks, it should display all results in page=0 if pageSize=2. It seems to be an internal bug on pagination.

      It happens if a custom advanced query[1] returns duplicate records[2] due to the oe_id assigned to it (i.e. user task node is assigned to two groups - manager,developer - and an user is assigned to both groups, it will generate duplicate records in audittaskimpl table:

      [1] SELECT ti.*, oe.id as oeid FROM AuditTaskImpl ti, PeopleAssignments_PotOwners po, OrganizationalEntity oe WHERE ti.taskId= po.task_id AND po.entity_id = oe.id;

      [2] Records returned after executing query above:
       id |     activationtime      | actualowner | createdby |        createdon        | deploymentid | description | duedate |  name  | parentid | priority |           proc
      essid            | processinstanceid | processsessionid | status | taskid | workitemid |   oeid    
      ----+-------------------------+-------------+-----------+-------------------------+--------------+-------------+---------+--------+----------+----------+---------------
      -----------------+-------------------+------------------+--------+--------+------------+-----------
        1 | 2017-12-28 16:45:50.196 |             |           | 2017-12-28 16:45:50.196 | pagination   |             |         | Task_1 |       -1 |        0 | pagination.myP
      aginationProcess |                 1 |                1 | Ready  |      1 |          1 | developer
        1 | 2017-12-28 16:45:50.196 |             |           | 2017-12-28 16:45:50.196 | pagination   |             |         | Task_1 |       -1 |        0 | pagination.myP
      aginationProcess |                 1 |                1 | Ready  |      1 |          1 | manager
        2 | 2017-12-28 16:47:35.549 |             |           | 2017-12-28 16:47:35.549 | pagination   |             |         | Task_1 |       -1 |        0 | pagination.myP
      aginationProcess |                 2 |                1 | Ready  |      2 |          2 | developer
        2 | 2017-12-28 16:47:35.549 |             |           | 2017-12-28 16:47:35.549 | pagination   |             |         | Task_1 |       -1 |        0 | pagination.myP
      aginationProcess |                 2 |                1 | Ready  |      2 |          2 | manager
      (4 rows)
      

      Then by calling rest endpoint [3] to the custom registered query, it is internally converted by dashbuilder API or kie-server to the following query [4] which applies some filters:

      [4]
      16:48:56,654 DEBUG [org.dashbuilder.dataprovider.sql.JDBCUtils] (http-192.168.1.101:8080-2) SELECT id, activationtime, actualowner, createdby, createdon, deploymentid, description, duedate, name, parentid, priority, processid, processinstanceid, processsessionid, status, taskid, workitemid, oeid FROM (select ti.*, oe.id as oeid from audittaskimpl ti, peopleassignments_potowners po, organizationalentity oe where ti.taskid= po.task_id and po.entity_id = oe.id) AS "dbSQL" WHERE (actualowner = 'brmsuser' OR (oeid = 'admin' OR oeid = 'analyst' OR oeid = 'developer' OR oeid = 'manager' OR oeid = 'kie-server' OR oeid = 'brmsuser')) LIMIT 4

      Note: getAllTaskInstancesWithCustomVariables4 is the advanced custom query registered against kie-server.

      Result: This rest endpoint displays only one task in page=0 and the other task result in page=1. It should display the two tasks in page=0 since pageSize passed is 4.

      The root caused is explained by William in this comment.

              swiderski.maciej Maciej Swiderski (Inactive)
              rhn-support-wsiqueir William Siqueira
              Karel Suta Karel Suta
              Karel Suta Karel Suta
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: