-
Notifications
You must be signed in to change notification settings - Fork 390
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(drain): consider checking parent jobs when draining #992
fix(drain): consider checking parent jobs when draining #992
Conversation
tests/test_queue.ts
Outdated
expect(keys.length).to.be.eql(5); | ||
|
||
const countAfterEmpty = await queue.count(); | ||
expect(countAfterEmpty).to.be.eql(1); |
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.
this job is the parent that was moved to wait state, before it was in waiting-children state
rcall("ZREM", parentPrefix .. "waiting-children", parentId) | ||
|
||
if rcall("HEXISTS", parentPrefix .. "meta", "paused") ~= 1 then | ||
rcall("RPUSH", parentPrefix .. "wait", parentId) | ||
if parentPrefix == baseKey then |
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.
we should only delete those records that belongs to the same queue that runs this script, on the contrary case, move it to wait or paused
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.
Is this ready?
Yes, this one is ready |
``` | ||
|
||
{% hint style="info" %} | ||
Locked jobs (in active state) could not be removed. An error would be thrown. |
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.
"could" -> "can", "would" -> "will"
|
||
There are 2 possible cases: | ||
|
||
1. There are not pending dependencies; in this case the parent is moved to wait state, we may try to process this job. |
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 the wait status"
There are 2 possible cases: | ||
|
||
1. There are not pending dependencies; in this case the parent is moved to wait state, we may try to process this job. | ||
2. There are pending dependencies; in this case the parent is kept in waiting-children state. |
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.
-> "in the waiting-children status"
|
||
# Having pending dependencies | ||
|
||
We may try to remove all its pending decendents first. |
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.
"decendents" -> "descendents"
We may try to remove all its pending decendents first. | ||
|
||
{% hint style="warning" %} | ||
in case one of the children is locked, we would stop the deletion process. |
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.
"in" -> "In", "we would" -> "it will"
``` | ||
|
||
{% hint style="warning" %} | ||
Parent jobs that belong to the queue being drained will be kept in **waiting-children** state if they have pending children, but if they do not have any pending children they will just be removed. |
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.
state -> status
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.
LGTM, just a couple of typos in the documentation
## [1.67.3](v1.67.2...v1.67.3) (2022-01-28) ### Bug Fixes * **drain:** consider checking parent jobs when draining ([#992](#992)) ([81b7221](81b7221))
🎉 This PR is included in version 1.67.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
When we call drain, we were not considering checking the parent dependencies, so those records could be moved to wait or paused depending on how many dependencies they still have, this way we don't end in an scenario where parents have dependencies but the actual child record is deleted