-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(engine, engine-rest-core) Add a query criteria to retrieve all executing jobs #4494
base: master
Are you sure you want to change the base?
Changes from 3 commits
9d41554
e4d5449
62d53a1
560e263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -419,6 +419,14 @@ | |||||||||||||||||||||||||
<if test="suspensionState != null"> | ||||||||||||||||||||||||||
and RES.SUSPENSION_STATE_ = #{suspensionState.stateCode} | ||||||||||||||||||||||||||
</if> | ||||||||||||||||||||||||||
<if test="acquired"> | ||||||||||||||||||||||||||
AND | ||||||||||||||||||||||||||
RES.SUSPENSION_STATE_ = 1 | ||||||||||||||||||||||||||
AND | ||||||||||||||||||||||||||
RES.LOCK_EXP_TIME_ IS NOT NULL | ||||||||||||||||||||||||||
AND | ||||||||||||||||||||||||||
RES.LOCK_EXP_TIME_ > #{now, jdbcType=TIMESTAMP} | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @venetrius Thanks for the clarification. I will update the suggestions. Thank you again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @venetrius can you help me understanding the reason of splitting the query? If we split and user only set the query as 'acquired' (without setting the active flag, i.e false by default), wouldn't the query will also include suspended jobs along with active? Isnt the definition of 'acquired' means the job has to be 'active' and excludes all 'suspended' jobs? I have also noticed the similar logic in 'executable' flag. It excludes the suspended process instances but does not exclude suspended jobs. and here is what document about it: I am wondering if its intended. Can you please give me little bit a clarity on it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @prajwolbhandari1, However, there is a corner case: if a job is acquired and running at the exact moment you suspend it, Camunda 7 marks it as suspended in the database but does not interrupt the currently running transaction. That job can keep executing in code until it finishes or fails. In that brief window, a suspended job could still be “in flight.” So if your query filters out all suspended jobs (SUSPENSION_STATE_ = 2), you might miss a job that’s actually finishing up in the background. For that reason, relying on a single “acquired and active” filter cannot guarantee you’ve captured every job that might still be running. In most use cases, you either:
The main takeaway is that “suspension” in Camunda prevents future acquisition and retries, but does not forcibly interrupt a job that’s mid-execution. That’s why a query filtering out suspended jobs might overlook an already-running job that’s about to finish. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||
</if> | ||||||||||||||||||||||||||
<if test="isTenantIdSet"> | ||||||||||||||||||||||||||
<if test="tenantIds != null && tenantIds.length > 0"> | ||||||||||||||||||||||||||
and ( RES.TENANT_ID_ in | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check if suspension state is 1 one can use the existing
active
filter