grantcarthew / node-rethinkdb-job-queue

A persistent job or task queue backed by RethinkDB.
https://github.com/grantcarthew/node-rethinkdb-job-queue/wiki
MIT License
157 stars 16 forks source link

Queue creates extra job #65

Closed viridia closed 7 years ago

viridia commented 7 years ago

My app has a GUI which displays the current list of jobs in progress; one thing I see that's kind of odd is that occasionally there's an extra Job object that I didn't create. This Job object has state 'created' (it was never in a queue), has no custom properties (unlike my other jobs) - but the Query.findJobs() method does return it with the list of other jobs. I don't think this is a bug in my code, because I only have one call to createJob() and it always puts in a bunch of extra properties (not to mention doing json-schema validation on them). If I delete this extra job and wait a few minutes, another similar job will appear.

This is only an issue because of the fact that I'm displaying the list of jobs to the user and don't want to confuse them. I could filter this one out but I'd like to understand what's going on.

grantcarthew commented 7 years ago

Is it the State Document?

I'm planning on changing the Id of the state document to something simple.

viridia commented 7 years ago

Ah, yes it is, I hadn't read that part. So basically I just need to exclude that when processing the results from Queue.findJobs().

grantcarthew commented 7 years ago

Queue.findJob exposes the standard RethinkDB filter features so it will return the State Document. I could add a filter to prevent the State Document from being returned. Not sure on this.

I could also extend the Queue object api to add a Queue.getStateDocument or something similar. It shouldn't be needed though. The document is just a side effect of the global distributed events.

I am planning on adding more to the state document though with the Rate Limiting feature as indicated in #61

grantcarthew commented 7 years ago

We done here? Any feedback or ideas?

viridia commented 7 years ago

Close it.