seomoz / qless-core

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

Encode math.huge #66

Closed moteus closed 7 years ago

moteus commented 7 years ago

I found problem on my test installation (Windows Redis-3.0 x64). redis.call( ..., math.huge ...) convert value to 1.INF# string and I get error when I go to web http://localhost:5678/queues/test-queue/running Qless::LuaScriptError at /queues/test-queue/running ERR min or max is not a float App send this commands to redis

1484839149.823831 [0 127.0.0.1:2376] "evalsha" "3f9682e7ddb462dca8c60a26d5e88ac70c3a49e9" "0" "jobs" "1484839149.8228312" "running" "test-queue" "0" "25"      
1484839149.823831 [0 lua] "zrangebyscore" "ql:q:test-queue-locks" "1484839149.8228312" "1.#INF" "LIMIT" "0" "25"                                               

So I suggest replace math.huge to +inf string like in this example

redis.call('zrangebyscore', queue:prefix('locks'), now, "+inf", 'LIMIT', offset, count)

Upadate Basic testcase

127.0.0.1:6379> eval "redis.call('set', 'a', math.huge) local a=redis.call('get', 'a') return {a, math.huge}" 0
1) "1.#INF"
2) (integer) -9223372036854775808
b4hand commented 7 years ago

Here's what I get when I run your test case:

127.0.0.1:6379> eval "redis.call('set', 'a', math.huge) local a=redis.call('get', 'a') return {a, math.huge}" 0
1) "inf"
2) (integer) -9223372036854775808
moteus commented 7 years ago

Did you try this on Windows. On my Debian system and on Travis service I also get inf. But on Windows math.huge value converts to 1.#INF string.

b4hand commented 7 years ago

I don't have a Windows machine to test on, so I guess I'll trust your output.