Comments (10)
But the call to 'client.network.write' adds data to requests
If I'm not mistaken:
local reply = cmd(client, ...) <--- this will end up inserting data in 'requests' table
-- so here #requests can't be zero
table_insert(parsers, #requests, reply.parser)
return reply
from redis-lua.
sounds reasonable, but in particular situation, request is empty, that's a sure thing. and lua don't allow #2 argument to be 0, so an empty table can't use table.insert with #2 argument, which is a strange design i think.
if Line 516 isn't wrong, then the responsibility falls to the code before it by not catching the error in advance.
from redis-lua.
Do you have a test case to reproduce the error?
from redis-lua.
Not sure I understand what the issue is, any tiny snippet of code to reproduce it?
from redis-lua.
I'm seeing this issue as well.
redis-lua
2.0.4-1 (installed) - /usr/local/lib/luarocks/rocks
local redis = require("redis")
local r = redis.connect()
r:pipeline(function(pipe)
pipe:zadd("FOO", 1, "BAR")
pipe:zadd("FOO", 2, "BAZ")
end)
lua: /usr/local/share/lua/5.2/redis.lua:802: /usr/local/share/lua/5.2/redis.lua:471: bad argument #2 to 'table_insert' (position out of bounds)
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.2/redis.lua:802: in function 'error'
/usr/local/share/lua/5.2/redis.lua:480: in function 'pipeline'
test.lua:5: in main chunk
[C]: in ?
from redis-lua.
@benwilber Did you find a fix for this?
from redis-lua.
I got the same problem, but it seems that it comes from lua version:
in 5.1:
t = {}
table.insert(t, 1, nil)
print(#t) --> 0, but
table.insert(t, 2, nil) --> no error
in 5.2 and 5.3:
t = {}
table.insert(t, 1, nil)
print(#t) --> 0
table.insert(t, 2, nil) --> ERROR: bad argument #2 to 'insert' (position out of bounds)
corrected for me by changing
in pipeline function:
table_insert(parsers, #requests, reply.parser)
by
parsers[#requests] = reply.parser
I'm working on a more complete patch and I submit a pull request
from redis-lua.
π well done @cedroyer! This seems to affect Lua >= 5.2 indeed.
from redis-lua.
I think the correct fix is to change:
table_insert(parsers, #requests, reply.parser)
to:
table_insert(parsers, reply.parser)
This keeps the requests and parsers tables parallel, i.e. for requests[n]
the correct parser is parsers[n]
.
from redis-lua.
I disagree, if you use:
table_insert(parsers, reply.parser)
and reply.parser
is nil
(and that seems to be the case), your table won't change and the next parser you add in parsers will be insert at the wrong place (n-1), that's why table_insert(parsers, #requests, reply.parser)
was used in the library.
use parsers[#requests] = reply.parser
works for me with lua 5.3 and I think it also works for lua 5.1 and 5.2.
from redis-lua.
Related Issues (20)
- How do I use a redis URI to connect
- how to set expire key:value for redis HOT 1
- How to use zrevrangebyscore with limits?
- next release? HOT 1
- the pipline of hmset
- Pub/Sub is not tolerant of timeouts
- The `hmget` command fails to retrieve a second argument if the first argument is nil HOT 1
- Connect ignores database number in path of URL
- Support for rejson HOT 2
- ImportError: BasePipeline with redis-3.2.1 HOT 1
- Is the redis connect is managed by this library?
- Cannot specify redis db index HOT 1
- exporting global variable makes imposible to use redis inside any prosody plugin HOT 1
- ZPOPMIN attempt to call a nil value
- Socket FD leak on :quit()/:shutdown() HOT 2
- request.multibulk
- helpοΌοΌοΌοΌ HOT 2
- help!!! redis-pool how to achieve
- Could you support redis cluster mode
- redis:expireat(key,unix_time) reset key
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redis-lua.