Nakoa McCullough Wrote:
-------------------------------------------------------
> I would like to add a couple of functions to the
> lua module proxy.
>
> 2. I would like to add a sleep function that does
> not completely peg the CPU (ie. while (true))
> This would be helpful for our master-master
> failover.
>
From what I understand, each call to the Lua script requires it to return in order for Proxy to continue on with the current connection's operation.
I tried sleep inside the Lua script, and noticed Proxy pauses during the sleep period.
The Lua script is not a separately executed thread in Proxy. Instead it is more like part of the decision process of the Proxy thread written in C which actually decides what to do.
If you sleep inside the Lua script, you are pausing MySQL Proxy from continuing on.
I would instead recommend the ability to execute independent threading of executed Lua code invoked at start time.
Say you have a function in your Lua Script called threadOne.
execute: ./sbin/mysql-proxy --proxy-lua-script=script.lua --lua-thread=threadOne
It would execute in a separate thread outside the main threaded Proxy core for handling connections, yet still have access to the global.* variables.
This way we can make decision on MySQL failover outside the main connection processing, and then hand those evaluations over to the main processing through the global.* variables.
I would think this could be easy to implement, as just starting up a thread that executes the Lua script function in the same fashion MySQL Proxy does it now as part of the decision making process for handling connections.
The difference, no connections rely on this independent thread execution
And I would like to be able to call multiple --lua-thread options.
Say:
./sbin/mysql-proxy --proxy-lua-script=script.lua \
--lua-thread=threadOne \
--lua-thread=threadFromFunctionCallTwo \
--lua-thread=threadFromFunctionCallThree \
--lua-thread=Etc...
-- lua-script.lua --
function connect_server ()
...
end
function threadOne ()
...
end
function threadFromFunctionCallTwo ()
...
end
function threadFromFunctionCallThree ()
...
end
-- end script --
Currently I have the failover negotiation in a processes outside MySQL Proxy, which injects the evaluations into MySQL Proxy.
My process of doing this is outlined in my article:
http://dev.mysql.com/tech-resources/articles/failover-strategy-part3.html
-RG