Bug #63908 | mysql-proxy with LUA script get stuck when the clients' concurrency too much | ||
---|---|---|---|
Submitted: | 3 Jan 2012 4:28 | Modified: | 26 Jan 2012 3:04 |
Reporter: | zhongliang kang | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Proxy | Severity: | S1 (Critical) |
Version: | 0.8.2 | OS: | Linux (Suse10-2.6.16.60-0.21 ) |
Assigned to: | CPU Architecture: | Any | |
Tags: | mysql-proxy concurrency stuck |
[3 Jan 2012 4:28]
zhongliang kang
[3 Jan 2012 4:44]
zhongliang kang
and more: we try to add a test print at : chassis-event-thread.c 166 unsigned int m_pid=pthread_self(); 167 if(received>0){ 168 g_message(" %u now queue event num: %d\n",m_pid,received); 169 } 170 /* the pipe has one . per event, remove as many as we received */ and in the output of mysql-proxy.log ,we got the follow output: my question is : if the proxy get stuck has some relation with the number of event in the queue? -----------mysql-proxy.log---------------- 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 4 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 1 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 4 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 46 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 15 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 17 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 15 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 14 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 16 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 16 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 17 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 17 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 15 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 75 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 40 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 95 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 32 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 41 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 29 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 79 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 73 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 11 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 73 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 68 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 19 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 113 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 46 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 7 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 6 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 54 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 49 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 37 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 153 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 22 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 47 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 20 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 23 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 39 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 126 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 28 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 31 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 118 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 73 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 96 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 3 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 68 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 83 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 108 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 20 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 153 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 120 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 24 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 68 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 45 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 68 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 55 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 78 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 49 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 114 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 74 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 69 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 68 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 218 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 54 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 43 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 124 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 132 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 112 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 217 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 71 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 64 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 120 2012-01-03 11:37:21: (message) 1082132800 now queue event num: 178 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 89 2012-01-03 11:37:21: (message) 1090525504 now queue event num: 213 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 64 2012-01-03 11:37:21: (message) 1107310912 now queue event num: 112 2012-01-03 11:37:21: (message) 3159565600 now queue event num: 225 2012-01-03 11:37:21: (message) 1098918208 now queue event num: 88 ---------------stuck here------------------
[3 Jan 2012 10:45]
zhongliang kang
And one more question: #event-threads event-threads = 5 when the mysql-proxy get stuck, by strace all the mysql-proxy's threads,like bellow,All the threads are send the event,and dead here,that means no thread to receive the event? --------- mysql@NODE_2:/usr/local/mysql-proxy-release-sky/bin> pstree -p 12807 mysql-proxy(12807)-+-{mysql-proxy}(12808) |-{mysql-proxy}(12809) |-{mysql-proxy}(12810) `-{mysql-proxy}(12811) mysql@NODE_2:/usr/local/mysql-proxy-release-sky/bin> strace -p 12807 Process 12807 attached - interrupt to quit sendto(4, ".", 1, 0, NULL, 0 <unfinished ...> Process 12807 detached mysql@NODE_2:/usr/local/mysql-proxy-release-sky/bin> strace -p 12808 Process 12808 attached - interrupt to quit sendto(4, ".", 1, 0, NULL, 0 <unfinished ...> Process 12808 detached mysql@NODE_2:/usr/local/mysql-proxy-release-sky/bin> strace -p 12809 Process 12809 attached - interrupt to quit sendto(4, ".", 1, 0, NULL, 0 <unfinished ...> Process 12809 detached mysql@NODE_2:/usr/local/mysql-proxy-release-sky/bin> strace -p 12810 Process 12810 attached - interrupt to quit sendto(4, ".", 1, 0, NULL, 0 <unfinished ...> Process 12810 detached mysql@NODE_2:/usr/local/mysql-proxy-release-sky/bin> strace -p 12811 Process 12811 attached - interrupt to quit sendto(4, ".", 1, 0, NULL, 0 <unfinished ...> Process 12811 detached ------------
[14 Jan 2012 10:22]
Sveta Smirnova
Thank you for the report. You wrote: ----<q>---- when I tried to test mysql-proxy without lua script,when the clients' concurrency is 5000,each client got 1000 query, mysql-proxy can handled the task in 163 SEC, and the result is OK. But when I tried to test mysql-proxy with LUA script,the content as above,when the clients' concurrency is 5000(even 1000,in test), the mysql-proxy got stuck and didnot work any more. Then I repeated the test , the case repeated. ----</q>---- What is the difference between 2 cases? I see you mentioned same 5000 number of concurrent client. Also have you tried to connect to MySQL server without proxy? Can it survive such a workload?
[16 Jan 2012 6:16]
zhongliang kang
----<q>---- when I tried to test mysql-proxy without lua script,when the clients' concurrency is 5000,each client got 1000 query, mysql-proxy can handled the task in 163 SEC, and the result is OK. But when I tried to test mysql-proxy with LUA script,the content as above,when the clients' concurrency is 5000(even 1000,in test), the mysql-proxy got stuck and didnot work any more. Then I repeated the test , the case repeated. ----</q>---- What is the difference between 2 cases? I see you mentioned same 5000 number of concurrent client. Also have you tried to connect to MySQL server without proxy? Can it survive such a workload? ============= The difference is: case 1 run with no lua script,but case 2 did. When I tested at the same concurrency of 5000, the proxy with lua script got stuck(case 2),but case 1 (with no lua script) worked good. And I tried the test with no proxy,5000 test clients conneted to mysql server directly,It was OK. This case can repeat at up to 5000 client's concurrency. I guess if this would happened when there is too much event generate by the proxy with lua script,and the proxy cannot handle them in time,so get stuck?
[16 Jan 2012 18:44]
Sveta Smirnova
Thank you for the feedback. Got it. Please also send command you use to start MySQL Proxy, so I can imitate your test as best as possible.
[16 Jan 2012 18:49]
zhongliang kang
OK. Thank you for your help :) the start command is below: ./mysql-proxy --defaults-file=/etc/proxy_my.cnf #cat /etc/proxy_my.cnf |grep -v "#" [mysql-proxy] log-file = /usr/local/mysql-proxy/log/mysql-proxy.log log-level = debug admin-address=0.0.0.0:4401 admin-username=proxy admin-password=proxy admin-lua-script=/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua proxy-address=0.0.0.0:4406 proxy-backend-addresses=10.164.5.111:3306 basedir=/usr/local/mysql-proxy daemon = true event-threads = 5
[25 Jan 2012 19:31]
Sveta Smirnova
Thank you for the feedback. Verified, although in my case when threads stuck depends from quantity of parallel threads and not only lua script. Also without lua script I only need 2750 threads to notice "stuck" while with lua script I need more. Your Lua code contained error, I used following: proxy.global.master_index = proxy.global.master_index or 1 function read_query(packet) proxy.connection.backend_ndx = proxy.global.master_index end
[25 Jan 2012 19:32]
Sveta Smirnova
program which creates threads, then sends query
Attachment: bug63908_1.cpp (text/x-c++src), 1.29 KiB.
[26 Jan 2012 3:04]
zhongliang kang
Verified, although in my case when threads stuck depends from quantity of parallel threads and not only lua script. Also without lua script I only need 2750 threads tonotice "stuck" while with lua script I need more. --- Yes,I used mysqlslap,and when 5000 threads without lua, the proxy got stuck. At first I didnot notice its a bug,so I ignored it :( I'm sorry about the lua script error,I'm a beginner to lua. Thank you for your verified,and thank you for your work! Hi Sveta : One of my friends had fix the stuck problem by another way,we are not sure if that is ok,I'll ask him to share his changes later.