-
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?
feat(engine, engine-rest-core) Add a query criteria to retrieve all executing jobs #4494
Conversation
…xecuting jobs related to: camunda#4470
…k and processInstance
@venetrius any update on this? |
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.
The proposed logic does not exactly query jobs that are currently executing.
select * from act_ru_job where LOCK_EXP_TIME_ is not null and suspension_state_=1 and LOCK_EXP_TIME_ > currenttime
It is possible that LOCK_EXP_TIME_ > currenttime
but a job is not executing:
LOCK_EXP_TIME_
is first set when the job executor has acquired the job. However an acquired job might not get executed right away.
If a job failed LOCK_EXP_TIME_
might be updated with an icrement as part of the retry policy
It is also not guaranteed that no job is running if LOCK_EXP_TIME_ <= currenttime
. In a case where a job does not return within the LOCK_EXP_TIME_
the job can be acquired by a (different of same) job executor.
I recommend visiting our documentation on the The Job Executor
If the behaviour you want to achieve is still met with this query then one option would be to split executing
into two filters.
A query criteria to test if suspension is 1 already exists it is called active
A query criteria that checks if a job has a LOCK_EXP_TIME_
value in the future could be called aquired
.
Once the acquisition thread acquires a job, it sets LOCK_EXP_TIME_ in some future time and put that job in the job queue right? Isn't it mean its currently "executing"? However, I agree there might be other possible outcomes after that but at that point when the LOCK_EXP_TIME_ is in future time and suspension_state_ is active, my understanding is executing. Also, I am considering retries as "executing" since its the part of a job that is being executed.
Can the job be acquired though because the suspension_state_ will in active state not in suspended even though
@venetrius Thank you for your reply. Please review my above comments. Can you please suggest to add/remove from the query that I came up that would retrieve jobs that are currently executing? |
@venetrius any thoughts? |
@yanavasileva @venetrius any thoughts on this? |
Hi @prajwolbhandari1, |
@venetrius any thoughts or direction would be helpful. |
Hi @prajwolbhandari1, The API already supports the
Then when you can call the API with
the same SQL would be executed then what the current changes would introduce with the |
Perfect @venetrius and it makes sense, let me change the flag from 'executing' to 'acquired'. |
Closing due to lack of requested feedback. If you would like us to look at this, please provide the requested information to re-open the PR. |
@venetrius @yanavasileva can you please reopen this PR? I am in process of working on changes. Is it easier to open a new PR together OR reopen this? I am ok with either one. Thanks! |
Hi @prajwolbhandari1, |
@venetrius Just pushed a new commit. Please take a look at it. Thanks again @venetrius |
Thanks @prajwolbhandari1, |
Sure. Sounds good. Thanks! |
Hi @prajwolbhandari1, |
Sounds good. Thank you. |
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.
Hi @prajwolbhandari1,
I see you renamed the filter.
The intent of my previous comment was to break out the single filter to two separate filters (active
and acquired
). I added comments and suggestions to try to make my point clear.
Please take a look and let me know if you have any questions / concerns.
"acquired": { | ||
"type": "boolean", | ||
"desc": "Only select jobs which are acquired, i.e., lock expiration date is not null, lock expiration | ||
date is in future and suspension state is 1. Value may only be `true`, as `false` is the default |
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.
date is in future and suspension state is 1. Value may only be `true`, as `false` is the default | |
date is in the future. Value may only be `true`, as `false` is the default |
To check if suspension state is 1 one can use the existing active
filter
<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 comment
The reason will be displayed to describe this comment to others. Learn more.
<if test="acquired"> | |
AND | |
RES.SUSPENSION_STATE_ = 1 | |
AND | |
RES.LOCK_EXP_TIME_ IS NOT NULL | |
AND | |
RES.LOCK_EXP_TIME_ > #{now, jdbcType=TIMESTAMP} | |
<if test="acquired"> | |
and | |
RES.LOCK_EXP_TIME_ is not null | |
and | |
RES.LOCK_EXP_TIME_ > #{now, jdbcType=TIMESTAMP} |
- In the code base SQL keywords or operators are written in lower case.
RES.SUSPENSION_STATE_ = 1
can be tested by the existingactive
filter
related to: #4470