Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    ndileep
    @ndileep
    2015/10/31 22:51:24 [error] 27515#0: 1 lua entry thread aborted: runtime error: content_by_lua(wbxnginx.conf:35):21: bad argument #1 to 'say' (non-array table found)
    stack traceback:
    coroutine 0:
    [C]: in function 'say'
    content_by_lua(wbxnginx.conf:35):21: in function <content_by_lua(wbxnginx.conf:35):1>, client: 10.24.211.154, server: $host, request: "GET / HTTP/1.1", host: "ndileep-vm2.cisco.com"
    2015/10/31 23:00:07 [error] 6465#0:
    1 lua entry thread aborted: runtime error: /usr/local/luajit/share/luajit-2.1.0-beta1/_cassandra.lua:91: attempt to index local 'self' (a nil value)
    Thibault Charbonnier
    @thibaultcha
    I don't think those errors are related to the libraries themselves. Can you paste your code?
    ndileep
    @ndileep
        location / {
    
             default_type 'text/plain';
    
             content_by_lua '
    
                local start = os.date()
                ngx.say("Start time: ", start);
    
                if jit then
                        ngx.say("LuaJIT version: ", jit.version)
                else
                        ngx.say("Not LuaJIT!")
                end
    
                local cassandra = require "cassandra"
                local session = cassandra.new()
                session:set_timeout(1000)
    
                local connected, err = session:connect("127.0.0.1", 9042)
                ngx.say("Connected to cassandra: ", connected);
                ngx.say("Error during connect: ", err);
    
                local timeout = session:get_reused_times();
                ngx.say("timeout: ", timeout);
                local keyname, err = session:execute("select keyname from kms.keynames limit 1")
                ngx.say(err);
             ';
        }
    Thibault Charbonnier
    @thibaultcha
    You cannot call ngx.say like this.
    Check the docs
    ndileep
    @ndileep
    The last statement was ngx.say(keyname) that I changed to ngx.say(err)
    Thibault Charbonnier
    @thibaultcha
    And if ou are using Lua-Cassandra, the doc says Cassandra:new, not Cassandra.new
    Yeah it's wrong
    ndileep
    @ndileep
    Let me restore the lua-cassandra and I'll get back to you. Thanks for the quick response
    Thibault Charbonnier
    @thibaultcha
    ngx.say expects the 1argument to be the log level
    Thibault Charbonnier
    @thibaultcha
    Also timeout is not what you think it is (your variable). And you might want to call close or put the socket in the connection pool at the end. Check the docs
    ndileep
    @ndileep
    Thanks a lot. it works now!!
    ndileep
    @ndileep
    timeout variable was just for some quick debugging. Yes, I need to use a connection pool
    Thibault Charbonnier
    @thibaultcha
    I am rewriting lua-cassandra to be cluster aware and have load balancing and retry policies
    ndileep
    @ndileep
    When would it be available?
    Is lua-cassandra non blocking now? Also, optimized for luaJIT?
    Thibault Charbonnier
    @thibaultcha
    Both are
    In the next few weeks
    ndileep
    @ndileep
    Hi thibaultCha, isn't this a valid syntax to delete a row?
    ok, err = session:execute("delete from kms.keynames where keyname = (?)", {kn})
    kn is of type string and has a valid value
    I am getting ok as nil
    ndileep
    @ndileep
    Code snippet is
                local cassandra = require "cassandra"
    
                local session = cassandra:new()
                session:set_timeout(1000) -- 1000ms timeout
    
                local connected, err = session:connect("127.0.0.1", 9042)
                assert(connected)
    
                local keyname, err = session:execute("select keyname from kms.keynames limit 1")
                if (#keyname == 1) then
                        kn = keyname[1].keyname
                        ok, err = session:execute("delete from kms.keynames where keyname = (?)", {kn})
                end
                session:close()
    Thibault Charbonnier
    @thibaultcha
    why the parenthesis around “?” ?
    The docs does show proper examples.
    I’m not sure it’s valid
    If you want a map use ? but with cassandra.map(…)
    as the binded value
    ndileep
    @ndileep
    Thanks!
    For nginx-lua-cassandra environment, is there any good library available for DB connection pool or we have build our own?
    Thibault Charbonnier
    @thibaultcha
    http://thibaultcha.github.io/lua-cassandra/examples/basic.lua.html Here you can see cassandra.uuid() as a binded value. It also works with .map, .list, etc...
    Also ok and kn are global variables in your code, be careful.
    ndileep
    @ndileep
    ok, thanks
    I'll test your retry/LB policies when it is ready :-)
    ndileep
    @ndileep
    When we insert a row, like... ok, err = session:execute
    ok, err = session:execute("insert into ...")
    is there a way to know from ok and err, if the row was already existing (since Cassandra does an upsert)?
    Thibault Charbonnier
    @thibaultcha
    No

    From the specs:

    "The rest of the body for a Void result is empty. It indicates that a query was successful without providing more information."

    Void results are what the binary protocol returns for INSERTs
    ysfkc
    @ysfkc
    hi