I am now trying rw-splitting.lua with Rails 2.3.2 (or newer) and MySQL 5.1.43.
I found that ActiveRecord's MySQL connector does the following after new connection is established:
1. Send SET NAMES if any encoding is specified in database.yml
2. Send "SET SQL_AUTO_IS_NULL = 0" to avoid "where id is null" matches last_insert_id.
These statements changes the connection's state, so not compatible with rw-splitting.
I know 1. is solved by server-side settings like the following article:
But I can not find the solution for 2. sql_auto_is_null is session-specific system variable and we can not set in my.cnf nor SET GLOBAL.. I tried using init-connect in [mysqld] section but it seems not working.
MySQL Proxy doesn't allow lua to identify specific connection in the pool.
I think these are not so rare case, but potential problem in using connection pool separated from applications.
So I request adding some LUA function call point like after_connect() which is
- You can send any queries by setting proxy.queries queue.
- Garranteed to be called immediately after read_auth_result()
- The queries are sent to the connection which is created just now.
If forging new query without any client-initiated query is not acceptable, "a function which is called before the first query is sent to a connection" may be enough. We can edit proxy.queries by append/prepend functions.
Sorry for no patches...