Need some help with manual backend switching
I've got two backends and I have to switch mysqlproxy from one to another manually.As I understood, now I can do it only by changing backend_ndx inside connect_server(). So, I try to do it via this lua script:
ndx=0
function connect_server( )
local file = io.open("/root/lua/backend_ndx", "r") -- file contains only desired backend index (0 or 1)
ndx = file:read()
proxy.connection["backend_ndx"] = ndx
print (proxy.connection["backend_ndx"])
end
function read_query( packet )
local file = io.open("/root/lua/backend_ndx", "r")
local new_ndx = file:read()
print ("< new ndx: " .. new_ndx .. " >")
if new_ndx ~= ndx then
proxy.response = {
type = proxy.MYSQLD_PACKET_ERR,
errmsg = "Backend has changed"
}
return proxy.PROXY_SEND_RESULT
end
proxy.queries:append(1, packet )
return proxy.PROXY_SEND_QUERY
end
It works fine, but when I stop mysql server on backend and already connected client tries to reconnect, mysqlproxy gets caught in an endless loop trying to connect to backend. Without line `proxy.connection["backend_ndx"] = ndx` it tries to reconnect only once, as I expected. What am I doing wrong? Help, please.
Subject
Views
Written By
Posted
Need some help with manual backend switching
3758
July 25, 2007 06:53AM
2477
July 26, 2007 09:49AM
2372
July 27, 2007 12:28AM
2406
July 27, 2007 05:02AM
2496
August 08, 2007 01:15AM
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.