2
votes

I am getting a strange error with lua script while running it on redis cluster.

the following script

--if keyCount ~= 1 or  KEYS[1] == nil then

--end

throws error:

(error) ERR Error compiling script (new function): user_script:3: 'end' expected (to close 'function' at line 1) near '<eof>'

Following is the redis-cli command I am using:

./redis-cli -h HOST -p PORT SCRIPT LOAD "$(cat 2.lua)"

It looks like a bug to me, how come a fully commented script needs an 'end' at the end!! Has someone seen this?

PS: I am posting the most reduced version of script where I am able to reproduce the issue, actually faced it in much bigger script while putting the line comments. Putting the multi line comment like --[[]] solves the issue, but this shouldn't be occurring at the first place! I am using Lua 5.1 and redis 3.0.x

1
Mhm. It definitely sounds like a bug. Could You please clarify the environment (OS, specifically)? There is slim chance that cat adds some crap You don't actually need. - Kamiccolo
It should not make a difference, but doesn't redis use Lua 5.1? - lhf
Lua v5.1 indeed and there is a recent fix to Redis that smells familiar: github.com/antirez/redis/issues/2951 - Itamar Haber
The current version of redis, 3.0.7, contains this fix. - lhf
take a look at stackoverflow.com/questions/729692/… Trailing new line should help you. - Alexander Altshuler

1 Answers

1
votes

Confirmed that its a bug with redis 3.0.5 (running Lua 5.1) , the issue is fixed in redis 3.0.7