← Back to team overview

mysql-proxy-discuss team mailing list archive

problem with connection pooling?

 

Hi -
I am trying to set up connection pooling such that 2 applications connect to
the proxy and share 1 actual connection to the database.  I do this by
letting the first connection go through unaltered, and then setting the
second attempted connection to use the first connection.  I don't want the
second connection to need to re-authenticate to the actual database, I just
want to send its queries out over the existing authenticated backend
connection.

I keep getting this error during read_query() when the second tries to use
the first connection:

2009-07-14 19:30:10: (critical) proxy-plugin.c.1129: I have no server
backend, closing connection
2009-07-14 19:30:10: (critical) network-mysqld.c.1188:
plugin_call(CON_STATE_READ_QUERY) failed

Here is my code:

if proxy.global.client_counter == nil then
proxy.global.client_counter = 0
end

local proto = assert(require("mysql.proto"))
local order = 0

function connect_server()
proxy.global.client_counter = proxy.global.client_counter + 1
order = proxy.global.client_counter
if order ~= 1 then
proxy.response = {
type = proxy.MYSQLD_PACKET_RAW,
packets = {
proto.to_challenge_packet({
server_status     = 2,
    server_version    = 50132,
    thread_id         = 12345678922222
})
}
}
return proxy.PROXY_SEND_RESULT
end
end

function read_query(stmt)
if order ~= 1 then
proxy.connection.backend_ndx = 1
return proxy.PROXY_SEND_QUERY
end
end

What am I doing wrong?  And FYI I am using 0.7.2.

Thanks much for the help.

Follow ups