plivo / sharq

The core SHARQ Library that powers SHARQ Server
http://sharq.io
MIT License
50 stars 14 forks source link

Fix requeue lua script crash #7

Closed ppai-plivo closed 3 years ago

ppai-plivo commented 5 years ago

Unlike user driven operation such as enqueue, dequeue and finish, requeue operation is a server side maintenance operation that has to be periodically invoked. The goal of requeue operation is to add expired jobs back to the queue if the job hasn't exceeded the number of times it can be requeued.

The requeue Lua script fetches multiple keys which may no longer exist, perhaps due to a race somewhere. This has been fixed at 2 known places where exceptions have been observed as follows:

user_script:45: attempt to perform arithmetic on local 'interval' (a boolean value)
user_script:21: attempt to compare number with nil

P.S: This PR also fixes existing unit tests. Running make test will now pass.