Insight post-function to increase object attribute value does not work as expected due to a race condition

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • None
    • Affects Version/s: Mindville - Pre Bundled
    • 4
    • Severity 2 - Major
    • 0

      Issue Summary

      Insight post-function to increase object attribute value does not work as expected due to a race condition.

      In particular, if the object attribute value gets increased at roughly the same time on different tickets' transition:

      • The first transition will execute the post-function and increase the value
      • At roughly the same time, the second transition will execute the post-function and consider old values, and not the new ones made by the first transition.
      • This is reproducible only if we are triggering transitions from two different Jira nodes in DC environment.

      Steps to Reproduce

      1. Create a new object type (in this example, it's called Sequences)
      2. Inside this object type, add two new Integer-type attributes (in this example, we will call them Code 1 and Code 2)
      3. Create an object of Sequences object type. Assign some integer values to Code 1 and Code 2 fields
      4. Create Insight field that will contain the object reference. Configure the field as follows (here, the field is called Sequence):
      5. Inside a workflow editor > go to some specific transition > add the following post-functions that will:
        • Associate specific, newly created object (step 3) with the custom field Sequence
        • Increase the existing attribute values for Code 1 and Code 2 fields, by 1
        • Store those new values into Seq 1 and Seq 2 custom fields
      6. Publish the workflow
      7. Create an issue inside of a project associated with the published workflow > edit Sequence field and select the object from step 3
      8. Create another issue inside of a project associated with the published workflow > edit Sequence field and select the object from step
      9. In a browser window, on node 1, on the 1st ticket, perform the transition that would call the post-functions and increment the Insight object attribute values
      10. At roughly the same same time, in another browser connected to Jira on node 2, on the 2nd ticket, perform the transition that would call the post-functions and increment the Insight object attribute values.

      Expected Results

      The 2nd transition increments the new Insight attribute values that were saved by the first transition:

      Actual Results

      There is some kind of race condition that happens if the Insight attributes values are increased at roughly the same time, from two different nodes. The 2nd transition will not take newly incremented values, but it will increase the original values as the 1st transition:

      Workaround

      Whenever multiple Insight PFs are set in the same transition, and trying to update the same object, you may face this race condition.
      As a workaround, you may have a Groovy Condition to the 3rd 4th and consecutive PFs, to delay its execution:

      sleep(n);
      return true

      where n is a value in ms, and should be adjusted (trial and error);
      e.g. for the 3rd PF set n=300 and for the 4th, set n=600.

      This will result in the 3rd PF executed with a 300ms delay, hence allowing the 1st and 2nd PFs to complete before executing.

      Notes

      • This issue is only reproducible on Jira DC environment, that contains at least 2 nodes.
      • The first and the second concurrent transition must be executed on different Jira nodes!

        1. screenshot-4.png
          screenshot-4.png
          94 kB
        2. screenshot-3.png
          screenshot-3.png
          41 kB
        3. screenshot-2.png
          screenshot-2.png
          29 kB
        4. screenshot-1.png
          screenshot-1.png
          70 kB

            Assignee:
            Unassigned
            Reporter:
            Marko Filipan (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: