Bug #42841 mysql-proxy / rw-splitting.lua closes client connection: resultset_is_needed
Submitted: 13 Feb 2009 16:28 Modified: 7 Dec 2009 9:12
Reporter: Olav Schettler Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Proxy: Scripts Severity:S3 (Non-critical)
Version:0.7.0 OS:Linux (RHEL)
Assigned to: Kay Roepke CPU Architecture:Any
Tags: mysql-proxy, resultset_is_needed, rw-splitting

[13 Feb 2009 16:28] Olav Schettler
Description:
Log entries in syslog: 

db1 mysql-proxy: 2009-02-13 17:10:40: (critical) proxy-plugin.c:247: read_query_result() in /usr/local/share/mysql-proxy/rw-splitting.lua tries to modify the resultset, but hasn't asked to buffer it in proxy.query:append(..., { resultset_is_needed = true }). We ignore the change to the result-set.
db1 mysql-proxy: 2009-02-13 17:10:40: (critical) proxy-plugin.c:1196: proxy.queries:append() in /usr/local/share/mysql-proxy/rw-splitting.lua can only have one injected query without { resultset_is_needed = true } set. We close the client connection now.

How to repeat:
My setup: 

/usr/local/sbin/mysql-proxy --daemon --keepalive --log-use-syslog --proxy-lua-script=share/mysql-proxy/rw-splitting.lua --proxy-backend-addresses=db1:3306 --proxy-read-only-backend-addresses=db2:3306

Versions:

mysql-proxy 0.7.0
  glib2: 2.18.4
  libevent: 1.1a
  admin: 0.7.0
  proxy: 0.7.0

The proxy runs on "db1" and sits between a CakePHP application and a MySQL server configured as master [db1] and slave [db2]

Suggested fix:
Modify mysql-proxy/rw-splitting.lua to include suggested resultset_is_needed = true - but where?
[13 Feb 2009 20:09] Olav Schettler
This seems to fix it:

*** /usr/local/share/mysql-proxy/rw-splitting.lua.orig  2009-02-11 11:42:17.000000000 +0100
--- /usr/local/share/mysql-proxy/rw-splitting.lua       2009-02-13 17:31:55.000000000 +0100
***************
*** 38,47 ****
                min_idle_connections = 4,
                max_idle_connections = 8,
  
!               is_debug = true
        }
  end
  
  ---
  -- read/write splitting sends all non-transactional SELECTs to the slaves
  --
--- 38,49 ----
                min_idle_connections = 4,
                max_idle_connections = 8,
  
!               is_debug = false
        }
  end
  
+ global resultset_is_needed = true
+ 
  ---
  -- read/write splitting sends all non-transactional SELECTs to the slaves
  --
[16 Feb 2009 7:44] Sveta Smirnova
Thank you for the report.

Could you please provide example of query you get this error for?
[16 Feb 2009 7:45] Sveta Smirnova
MySQL Proxy with rw-splitting.lua will print current query if it is run with debug turned on.
[17 Mar 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[25 May 2009 17:24] Diego Medina
See this file

http://bazaar.launchpad.net/~diego-fmpwizard/mysql-proxy/bug-43424/annotate/head%3A/lib/rw...

That file works with version 0.7.0 and greater.
It has all the changes you need.

And those changes will soon be part of the official mysql proxy branch
[13 Jul 2009 1:47] Diego Medina
This bug will depend on bug#46141 to be fully fixed.
[14 Jul 2009 12:36] Enterprise Tools JIRA Robot
Heidi Bergh-Hoff writes: 
Duplicate of PR-58 / 43424
[7 Dec 2009 9:12] MC Brown
A note has been added to the 0.8.0 changelog: 

The supplied script <filename>rw-splitting.lua</filename> had not been updated to use the new <literal>resultset_is_needed</literal> flag or updated <literal>proxy.connections</literal> structure.