I would like to prevent simultaneous execution of a particular post-function.
To put it simply:
Extending the question:
Would detecting this still be possible if I started a Thread inside the Post-Function, so that the main thread of the Post-Function finishes, while the Thread is still running in the background?
You can't actually perform two post-functions at the same time. Imagine the situation with two users looking at the same issue.
User 1 clicks "start progress", then user 2 hits the same a nanosecond later. The transition process that the first one is performing has moved the issue into a state (even if it's a status looped back to itself) where the second call the transition might be invalid, so it won't actually do anything. User 2 will get a message about the the state of the issue having being changed, so the transition they've requested is no longer valid. As the first transition blocks any others, you can't get into a state where the same post-function is running twice
Obviously, that only applies for the one issue. If your two users are looking at different issues, yes, the same post-function could run at the same time, but it will be running against two different issues, so they won't affect each other.
That makes a lot of sense. Thanks.
I assume if I chose to create a new thread from inside that post-function to do some task (so the user doesn't have to wait), then I wouldn't be able to prevent simultaneous executions of those threaded jobs, correct, unless maybe I have a "boolean" field "allow execution" on the context issue, set it to false in the main post-function, then set it to true again once the threaded task is finished?
Yes, that's the only way to do it, but you'll need to shift the logic a bit. You can't do this detection stuff in the post function, you'll need to do it in the conditions on the transition, basically "don't allow the transition to start if the flagged-as-running field is set"
I also want to question what you're doing. A post-function is only really suitable for processes that are single purpose, short and usually directly related to the issue being transitioned.
A long running process probably should be being run by something built to handle long running processes, and as you seem to want to prevent more than one of them running, we can be pretty sure it's not related to Jira. It sounds like your transition should not be running the process itself, but passing a trigger to a build server so that can handle all the work properly.
That's good advice. Thanks.
I wrote a script to export data to Google Sheets in a very specific format, while also doing some calculations before sending the data. I also couldn't do it via scheduled job, since one requirement was for it to be executed on demand. It works well, but I just wanted to make sure, that there can only ever be a single export script running at the same time, as anything else would just be bogging down the instance with redundant JQL searches etc.
We have an extremely customized instance here, and I agree, that passing a trigger to a build server would be best. It's a work-in-progress.
The manager’s daily activities include a list of challenges to reach high levels of efficiency for their teams. Part of these challenges is related to how to deal with the worklog systems sin...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event