Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-13706

TaskQuery 'ordering by id' broken in 7.15.0

    • Icon: Bug Report Bug Report
    • Resolution: Won't Fix
    • Icon: L3 - Default L3 - Default
    • None
    • 7.15.0
    • tasklist
    • None

      Environment (Required on creation): Camunda 7.15.0 Unittest

      Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket): I have created a simple testcase, see https://github.com/hmueller99/camunda-test.git

      Steps to reproduce (Required on creation):

      1. Run test and see/verify test failure
      2. Change camunda version in pom.xml to 7.14.0
      3. Run test and see/verify test success!

      Observed Behavior (Required on creation):

      With

      TaskQuery activeTasks = taskService.createTaskQuery().active().taskAssigned().orderByTaskId().asc();

      Tasks in query result list are not sorted by taskId.

      Expected behavior (Required on creation): 

      Task result list IS sorted by taskId.

       

        This is the controller panel for Smart Panels app

            [CAM-13706] TaskQuery 'ordering by id' broken in 7.15.0

            Holger Müller created issue -
            Holger Müller made changes -
            Description Original: h4. Environment (Required on creation): Camunda 7.15.0 Unittest
            h4. Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket): I have created a simple testcase, see https://github.com/hmueller99/camunda-test.git
            h4. Steps to reproduce (Required on creation):
             # Run test and see/verify test failure
             # Change camunda version in pom.xml to 7.14.0
             # Run test and see/verify test success!

            h4. Observed Behavior (Required on creation): Tasks in result list not sorted by taskId
            h4. Expected behavior (Required on creation):  Tasks in result list IS sorted by taskId
            h4.  
            New: h4. Environment (Required on creation): Camunda 7.15.0 Unittest
            h4. Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket): I have created a simple testcase, see [https://github.com/hmueller99/camunda-test.git]
            h4. Steps to reproduce (Required on creation):
             # Run test and see/verify test failure
             # Change camunda version in pom.xml to 7.14.0
             # Run test and see/verify test success!

            h4. Observed Behavior (Required on creation):

            With
            {quote}TaskQuery activeTasks = taskService.createTaskQuery().active().taskAssigned().orderByTaskId().asc();
            {quote}
            Tasks in query result list are not sorted by taskId.
            h4. Expected behavior (Required on creation): 

            Task result list IS sorted by taskId.
            h4.  
            Holger Müller made changes -
            Mentioned Roles
            Holger Müller made changes -
            Mentioned Groups

            Hi hmueller99,

            Thank you for providing an example that reproduces the issue. I can see it on my side as well. However, the behavior is expected.

            The reason that the sorting is not correct is the following.

            Keep in mind that Camunda doesn't recommend using the Database ID generator in production. There is a UUID generator available for use in production, which generates strings that include numbers and letters (e.g. "fe722567-d389-4933-a6ef-af8c26890981").

            I would recommend using the orderByTaskCreateTime() instead, as it is more reliable than the Task ID for sorting purposes.

            I will close this ticket, as it is not a bug report.

            Best,
            Nikola

            Nikola Koevski added a comment - Hi hmueller99 , Thank you for providing an example that reproduces the issue. I can see it on my side as well. However, the behavior is expected. The reason that the sorting is not correct is the following. The IDs assigned to the persisted entities of the process engine are strings that are stored in varchar SQL columns. As a result, SQL (and Java) sorts these values as strings, i.e. 1, 10, 2, 3... and not as numbers. You can read more about the Camunda ID generators here: https://docs.camunda.org/manual/7.15/user-guide/process-engine/id-generator/ . The reason why it works in 7.14, and not in 7.15, is that in 7.15 more data is generated before the tasks are persisted, leading to higher ID strings. Since the Database ID Generator is used ( https://docs.camunda.org/manual/7.15/user-guide/process-engine/id-generator/#the-database-id-generator ), these IDs are sequential numbers. However, as SQL sorts them as strings, "101" comes before "97", resulting in an error. Keep in mind that Camunda doesn't recommend using the Database ID generator in production. There is a UUID generator available for use in production, which generates strings that include numbers and letters (e.g. "fe722567-d389-4933-a6ef-af8c26890981"). I would recommend using the orderByTaskCreateTime() instead, as it is more reliable than the Task ID for sorting purposes. I will close this ticket, as it is not a bug report. Best, Nikola
            Nikola Koevski made changes -
            Mentioned Roles
            Nikola Koevski made changes -
            Mentioned Groups
            Nikola Koevski made changes -
            Assignee New: Nikola Koevski [ nikola.koevski ]
            Nikola Koevski made changes -
            Resolution New: Won't Fix [ 2 ]
            Status Original: Open [ 1 ] New: Closed [ 6 ]

              nikola.koevski Nikola Koevski
              hmueller99 Holger Müller
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: