seomoz / qless-core

Core Lua Scripts for qless
MIT License
85 stars 33 forks source link

Broken conditional logic in put.lua #11

Closed myronmarston closed 11 years ago

myronmarston commented 11 years ago

I'm debugging an issue we're having by looking at the qless monitoring output. I noticed this:

1360856508.527433 [8 lua] "zrem" "ql:w::jobs" "64c435622a9d402e9e51e3422cf81216"

This is coming from here:

-- If this had previously been given out to a worker,
-- make sure to remove it from that worker's jobs
if worker then
    redis.call('zrem', 'ql:w:' .. worker .. ':jobs', jid)
end

Worker is a blank string (or some other value that is concatenated as a blank string) but is truthy in the conditional. This may not be a real problem, but it was surprising to me and suggests some false assumptions being made that could cause other bugs later down the road, so I thought I'd mention it.

/cc @dlecocq

dlecocq commented 11 years ago

Good catch, and it's since been fixed: https://github.com/seomoz/qless-core/blob/fec33ce1734693fa5d801cd60222f0dcb7ddb3d8/queue.lua#L495