MySQL Forums
Forum List  »  Router & Proxy

Concurrent connections, lua script blocking
Posted by: Сар Рoе
Date: February 14, 2013 12:34PM

I'm finding that mysql proxy cannot process more than one request at a time while in a lua script. While processing the lua script, requests from other connections are blocked.


I've created a simple example with a proxy that execute's a sleep command. While this is running, the proxy does not process any other clients' commands.


Here's the script. It may be easier to read here: http://pastebin.com/NaZQ46NR


==== sleeptest.lua ====


local tokenizer = require("proxy.tokenizer")


function read_query( packet )
if string.byte(packet) == proxy.COM_QUERY then
local query = string.sub(packet, 2)

local tokens = tokenizer.tokenize(query)

if #tokens >= 1 and tokens[1].token_name == 'TK_LITERAL' then
local command = string.lower(tokens[1].text)

if command == 'sleep' then
if #tokens == 2 then
local sleep_time = tonumber(tokens[2].text)
os.execute("sleep " .. sleep_time)

proxy.response.type = proxy.MYSQLD_PACKET_OK
proxy.response.resultset = {
fields = {
{ type = proxy.MYSQL_TYPE_LONG, name="sleep_time", },
},
rows = {
{ sleep_time },
}
}
return proxy.PROXY_SEND_RESULT
end

end
end
end
end

function read_query_result(inj)

end



==== steps to reproduce ====

1. run mysql-proxy, loading sleeptest.lua
2. connect two clients to the proxy (A and B)
3. in client A, run the command "sleep 10;"
4. in client B, run the command "select 1;"

client B will not show the result of the query until client A's command has completed processing


I've tried the --event-threads option but setting it to a higher number doesn't seem to help.


Is this expected behaviour? Or am I missing something?



==== version info ====
mysql-proxy 0.8.3
chassis: mysql-proxy 0.8.3
glib2: 2.16.6
libevent: 1.4.13-stable
LUA: Lua 5.1.4
package.path: /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.lua;
package.cpath: /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.so;
-- modules
proxy: 0.8.3

Options: ReplyQuote


Subject
Views
Written By
Posted
Concurrent connections, lua script blocking
4410
February 14, 2013 12:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.