why find sendAt: {$lt: new Date(Date.now() - (this.interval * 4))} in __send? it's impossible.
fangjj opened this issue · comments
redim commented
I have a question:
- why find sendAt: {$lt: new Date(Date.now() - (this.interval * 4))} in __send? it's impossible.
___send(ready) {
this.collection.findOneAndUpdate({
$or: [{
isSent: false,
sendAt: {
$lte: new Date()
},
tries: {
$lt: this.maxTries
}
}, {
isSent: true,
sendAt: {
$lt: new Date(Date.now() - (this.interval * 4))
},
tries: {
$lt: this.maxTries
}
}]
}, {
$set: {
isSent: true,
sendAt: new Date(Date.now() + this.interval)
},
$inc: {
tries: 1
}
}
4 is this.failsToNext?
dr.dimitru commented
We expect to have no records in database, if record exists it means email wasn't sent or server encountered an error.
this.interval * 4
— used to reduce selection, also we give this task (this.interval * 4
) time to finish, if email wasn't send during that time-frame we assume it's zombie-taskisSent: true
— Means we started sending email, but as long as we're having this recored in DB it isn't actually sent (again, zombie-task)$lt: this.maxTries
— We won't recover zombie-tasks indefinitely
Home that helps, let me know wdyt :)
dr.dimitru commented
Closed due to silence at issue owner end.
Feel free to reopen it in case if the issue still persists on your end.