Closed david-martin closed 7 years ago
Wow, cool, thanks @david-martin. It sounds like your root cause analysis is correct. Quick question though. Do you think this will affect anything else in the system? I had a quick look through and I think it'll be fine.
I think Queue.prototype.size
would also need changing to be $lte
though this is more about consistency than trying to get the exact numbers. Would you be able to add this too?
I must admit, this also makes ping
, ack
and inFlight
compliment add
and size
better since $gt
is the perfect compliment to $lte
already.
@chilts I've updated the PR with the suggested change. From my understanding, it shouldn't affect anything else in the system.
That makes sense about the change complimenting the $gt
in other functions.
Released as v3.0.0 - not a major change, but I guess it is different (therefore, breaking). https://www.npmjs.com/package/mongodb-queue
Many thanks again @david-martin. :)
Hi @chilts, I had a look into the intermittent test failures and believe this should help. This problem only happens if the visible timestamp is exactly the same as the timestamp when trying to get a job.
This fix changes the
queue.get()
functionality slightly by using 'less than or equal to' ($lte) when comparing to the current time. This ensures that any newly added jobs to a queue can be retrieved straight away i.e. a test can add a job, then get it without having to wait until a small amount of time has passed and the job is 'visible'.