MySQL Forums
Forum List  »  Router & Proxy

show slave status not working
Posted by: sharif uddin
Date: July 05, 2011 11:01AM

current mysql-proxy

dpkg -l | grep mysql-proxy
ii mysql-proxy 0.8.0-1.2 high availability, load balancing and query modification for mysql

I have followed lots of tutorial found online soem are on the following links

I cannot seem to find a lua script that combines ro-balance and rw-splitting.

What I am testing out is how to execute show slave status in lua within mysql proxy.

the following is my test file

function connect_server()
print("--> a client really wants to talk to a server")
if (tonumber("%M")) % 2 == 0) then
proxy.connection.backend_ndx = 2
print("Choosing backend 2")
proxy.connection.backend_ndx = 1
print("Choosing backend 1")
print("Using " ..[proxy.connection.backend_ndx]

function read_query( packet )
if packet:byte() == proxy.COM_QUERY then
proxy.queries:append(5, string.char(proxy.COM_QUERY) .. "SHOW SLAVE STATUS", {resultset_is_needed = true} )
--, {resultset_is_needed = true} )
proxy.queries:append(1, packet, {resultset_is_needed = true})
proxy.queries:append(5, string.char(proxy.COM_QUERY) .. "SHOW SLAVE STATUS", {resultset_is_needed = true} )

return proxy.PROXY_SEND_QUERY

function read_query_result(inj)
if == 5 then
-- for row in inj.resultset.rows do
-- print("injected query returned: " .. row[1])
-- end

local res = inj.resultset
local fields = res.fields
local show_slave_status = {}

-- turn the resultset into local hash
for row in res.rows do
for field_id, field in pairs(row) do
show_slave_status[fields[field_id].name] = tostring(field)
if config.is_debug then
print(("[%d] '%s' = '%s'"):format(field_id, fields[field_id].name, tostring(field)))

-- print("query-time: " .. (inj.query_time / 1000) .. "ms")
-- print("response-time: " .. (inj.response_time / 1000) .. "ms")

This produces an error in the log file and does not return anything from the database. However if i change the "SHOW SLAVE STATUS" TO "SELECT NOW()" it works fine. How do i get to execute show slave status.

error is

2011-07-05 17:51:58: (critical) (read_query_result) [string "/usr/share/mysql-proxy/test.lua"]:48: attempt to call a nil value
2011-07-05 17:51:58: (critical) proxy-plugin.c.303: got asked to send a resultset, but ignoring it as we already have sent 2 resultset(s). injection-id: 5

or can be

2011-07-05 17:45:31: (critical) (read_query_result) [string "/usr/share/mysql-proxy/test.lua"]:47: .resultset.fields isn't available if 'resultset_is_needed ~= true'
2011-07-05 17:45:31: (critical) proxy-plugin.c:1235: proxy.queries:append() in /usr/share/mysql-proxy/test.lua can only have one injected query without { resultset_is_needed = true } set. We close the client connection now.

Does anyone know how to do this as there are no good documentation or samples on how to get this to work.

My overall goal is to combine rw-splitting and ro-balance in one lua script.

Edited 1 time(s). Last edit at 07/06/2011 02:18AM by sharif uddin.

Options: ReplyQuote

Written By
show slave status not working
July 05, 2011 11:01AM

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.