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
fix(job): fetch parent before job moves to complete #1580
Conversation
src/classes/job.ts
Outdated
@@ -516,6 +516,11 @@ export class Job< | |||
throw errorObject.value; | |||
} | |||
|
|||
const jobData = await Job.fromId(this.queue, this.id); |
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.
better to handle this logic atomically in moveToFinished script, so probably we may need to get parent values from there instead of providing it in args
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.
Added the fetch of the parent and the parentKey into the lua scripts.
Can we rerun the tests? On my local machine they went through |
Any updates here @roggervalf? |
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.
Sorry for the delay, LGTM
# [3.5.0](v3.4.2...v3.5.0) (2022-12-20) ### Bug Fixes * **job:** fetch parent before job moves to complete ([#1580](#1580)) ([6a6c0dc](6a6c0dc)) * **sandbox:** throw error when no exported function ([#1588](#1588)) fixes [#1587](#1587) ([c031891](c031891)) ### Features * **queue:** add getJobState method ([#1593](#1593)) ref [#1532](#1532) ([b741e84](b741e84))
When creating a flow with a long-running job in the beginning (e.g. takes multiple seconds) and during the processing of the job you want to add a new parent to this job (because it should run after the long-running job) it doesn't execute the job which was added after.
The root cause of this issue is, that the worker fetches the
Job
from redis before it moves it to active. When theJob
then finishes, the worker passes the previous fetched instance of the job tomoveToCompleted
. When an additional Job is added asparent
of the current processing job, it never gets executed because the instance doesn't have the correct parent key.This PR adds an additional "sync" of the parent key of the job before it gets moved to completed to have the current instance up to date when in the meantime a new parent was added.
Added a test which runs the following flow: