akira/exq

[Question] How do I get job score?

lordhx opened this issue · 3 comments

Exq.Api.find_failed/2 and Exq.Api.find_retry were marked as deprecated.
Message suggests to use /4 analogs, however it requires score

I'm not sure where should I get it from since enqueue only returns jid.
How does it suppose to work?

You can look at the exq_ui project for sample usage. Failed jobs are stored as ZSET in redis and without score, a full search is needed to find the job O(n), which will usually timeout or cause other issues. Having score will turn it into 0(1). As for how to get the score, you can use the failed/2 to paginate (basically the way UI works).

@ananthakumaran thank you for the quick answer.

I see that find_failed/4 works perfectly in exq_ui example when we already have the list of failed jobs preload. But in our case we only have jid that was returned by enqueue. We use find_failed/2 and find_retry/2 for troubleshooting.

I feel like finding job by only jid is still might be useful. Could we undeprecate these functions?

Just found out that find_failed/2 does the same work as failed/2 does under the hood. Now I know how to implement workaround for us

It only works if you have a small number of jobs in the retry queue. I understand this is very much desired, but the way data is stored (list, zset), we don't have an easy way to lookup based on jid. Doing any kind of scan on a system with a lot of jobs will bring other series issues (timeout, memory issues etc). These functions were used by the older version of exq_ui which didn't have proper pagination etc. Now we have solved those issues and marked the problematic apis as deprecated.