English 中文(简体)
Is there a set of complete documentation for mysql-proxy lua scripting?
原标题:

I am playing with scripting for mysql-proxy. What I am trying to accomplish is irrelevant. What I am finding, however, is that there appears to be elements of the lua interface that are undocumented. The big "smoking gun" I have is the disconnect_client() hook. I cannot find it documented anywhere in the official documentation, though it s used in an example on the explanation of the admin interface. It s also used extensively in the example docs. A quick grep shows its use in the following scripts included in the 5.5.8 distribution:

active-queries.lua
active-transactions.lua
load-multi.lua
ro-pooling.lua
rw-splitting.lua
tutorial-keepalive.lua

My other example that has caught my eye is the list of attributes for entries in the proxy.global.backends table. The documentation lists the following attributes:

dst.name
dst.address
dst.port
connected_clients
state
type

However, several of the example scripts reference a fairly complex element called pool. Take for instance tutorial-keepalive.lua:

local s = proxy.global.backends[i]
local pool     = s.pool
local cur_idle = pool.users[proxy.connection.client.username].cur_idle_connections

At first I thought it was being added somewhere else in the lua, but I ve looked and I can t find any code assigning into proxy.global.backends[i].pool.

So, two questions I suppose:

  1. Am I nuts? Please feel free to demonstrate how I ve overlooked the obvious and the documentation is really quite clear.
  2. Assuming I am correct, is there anywhere to find the complete documentation? A nice link would be great (though I couldn t google one up), but even "take a look at this .c file from the mysql-proxy distro that defines the interface". At least that would give me something to poke at.

Thanks

问题回答

Just opened Proxy/Lua myself. I m afraid, as with all things Mysql, once you dip under the covers you are on your own. The same goes for LUA. You will need other addons to LUA to do what you want to do, I would like to suggest: http://peterodding.com/code/lua/apr/docs/#shared_memory for the Apache Protable library binding... saved me a shedload of time. As for the internals of MySql, you will probably need to look in teh C source files, sadly, as we are in unexplored territory here.

One thing I have found is that the LUA structures in Mysql are not Lua tables, but Lua user data . This means that they are effectively shared memory, so are not changeable by Lua, as Mysql uses them too. I am going to try the luaposix library to see if I can get inbto them, as there are elements I would like to change, if possible.

Good luck

peter.colclough@toolstation.com





相关问题
Linking MySQL Workbench to my Remote Server

I ve just downloaded MySQL Workbench. But I don t quite understand how to syn this with the databases on my remote server. Work bench asks for "hostname" so I provided the hostname of my remote ...

mysql proxy r/w replication and temporary tables

I am doing master/slave replication on MySQL5.1 and r/w split with mysql proxy 0.8.x It works fine except with temporary tables. MySQL throws an error, that the temporary table is not existent. This ...

admin-username error of proxy

I tried to install proxy on development machine and I got the following error. /etc/init.d/mysql-proxyd start Starting mysql-proxy: 2011-02-26 15:51:45: (critical) admin-plugin.c:569: --admin-...

Best implementation for MySQL replication with Rails 3?

We re looking at potentially setting up replication for our primary MySQL database, and while setting up the replication seems pretty straight-forward, the application implementation seems a bit ...

Anything similar to MySQL Proxy for PostgreSQL? [closed]

I am looking for something similar to MySQL Proxy. The purpose is to modify incoming queries on the server. I am not looking for alternative ways to achieve the same. My best guess at the moment is to ...

Expiring memcached using mysql proxy when an update occurs?

I have mysql Proxy running which takes a query, performs an md5 on it, and caches the result into a memcached DB. the problem occurs when an update happens in the rails app that would invalidate that ...

热门标签