renecannao / proxysql-old

High Performance Proxy for MySQL
GNU General Public License v3.0
122 stars 18 forks source link

Crash on SET trough PHP (5.3.27) #70

Open Ithariel opened 9 years ago

Ithariel commented 9 years ago

While using the latest version of proxysql compiled with the libs the readme suggests the proxy crashes every time php tryes to "SET" a variable.

Example:

<?
mysql_connect("localhost", "user", "pass");
mysql_query("SET SQL_BIG_SELECTS=1");
mysql_select_db("db");
?>

Log output:

/opt/proxysql/proxysql(crash_handler+0x39)[0x4e7bf1]
/lib/libc.so.6(+0x31f50)[0x7f3bde159f50]
/lib/libc.so.6(+0x106d96)[0x7f3bde22ed96]
/opt/proxysql/proxysql[0x4eb359]
/opt/proxysql/proxysql[0x4eb5d5]
/opt/proxysql/proxysql(mysql_connpool_detach_connection+0x2e3)[0x4ebd4b]
/opt/proxysql/proxysql[0x4e5864]
/opt/proxysql/proxysql[0x4e5bfc]
/opt/proxysql/proxysql[0x4e1e91]
/opt/proxysql/proxysql[0x4e2645]
/opt/proxysql/proxysql[0x4e3a28]
/opt/proxysql/proxysql(mysql_thread+0xb20)[0x4e682d]
/lib/libpthread.so.0(+0x68ca)[0x7f3bded478ca]
/lib/libc.so.6(clone+0x6d)[0x7f3bde1f77dd]
<jemalloc>: Leak summary: 42822656 bytes, 124 objects, 22 contexts
<jemalloc>: Run pprof on "jeprof.22332.0.f.heap" for leak detail
2015-01-30 17:16:11 main.c:466:main(): ProxySQL exited with code 1 . Restarting!
2015-01-30 17:16:11 main.c:436:main(): Angel process is waiting 5 seconds before starting a new ProxySQL process
2015-01-30 17:16:16 main.c:448:main(): Angel process started ProxySQL process 22424
2015-01-30 17:16:16 main.c:532:main(): Opening Sockets
2015-02-02 11:23:09 admin.c:38:term_handler(): Received TERM signal: shutdown in progress...
2015-02-02 11:23:09 admin.c:38:term_handler(): Received TERM signal: shutdown in progress...
Ithariel commented 9 years ago

Additional informations:

MySQL server version is 5.5.40-0+wheezy1-log (Debian)

jemalloc statistics without bins:
___ Begin jemalloc statistics ___
Version: 3.6.0-0-g46c0af68bd248b04df75e4f92d5fb804c3d75340
Assertions disabled
Run-time option settings:
  opt.abort: false
  opt.lg_chunk: 22
  opt.dss: "secondary"
  opt.narenas: 96
  opt.lg_dirty_mult: 3
  opt.stats_print: false
  opt.junk: false
  opt.quarantine: 0
  opt.redzone: false
  opt.zero: false
  opt.xmalloc: true
  opt.tcache: true
  opt.lg_tcache_max: 17
  opt.prof: true
  opt.prof_prefix: "jeprof"
  opt.prof_active: true
  opt.lg_prof_sample: 16
  opt.prof_accum: true
  opt.lg_prof_interval: 20
  opt.prof_gdump: false
  opt.prof_final: true
  opt.prof_leak: true
CPUs: 24
Arenas: 96
Pointer size: 8
Quantum size: 16
Page size: 4096
Min active:dirty page ratio per arena: 8:1
Maximum thread-cached size class: 131072
Average profile sample interval: 65536 (2^16)
Average profile dump interval: 1048576 (2^20)
Chunk size: 4194304 (2^22)
Allocated: 61130048, active: 61546496, mapped: 264241152
Current active ceiling: 251658240
chunks: nchunks   highchunks    curchunks
             63           63           63
huge: nmalloc      ndalloc    allocated
            0            0            0

Merged arenas stats:
assigned threads: 53
dss allocation precedence: N/A
dirty pages: 15026:0 active:dirty, 0 sweeps, 0 madvises, 0 purged
            allocated      nmalloc      ndalloc    nrequests
small:       15701312        31505            0         2031
large:       45428736          238            0          238
total:       61130048        31743            0         2269
active:      61546496
mapped:     255852544
jeprof.14484.0.f.heap:
heap profile: 0: 0 [0: 0] @ heap_v2/65536

MAPPED_LIBRARIES:
00400000-00765000 r-xp 00000000 08:03 218900667                          /opt/proxysql/proxysql
00964000-00986000 rw-p 00364000 08:03 218900667                          /opt/proxysql/proxysql
00986000-009a4000 rw-p 00000000 00:00 0 
7fc208400000-7fc208c00000 rw-p 00000000 00:00 0 
7fc208c3f000-7fc208c4b000 r-xp 00000000 08:03 138808642                  /lib/libnss_files-2.11.3.so
7fc208c4b000-7fc208e4a000 ---p 0000c000 08:03 138808642                  /lib/libnss_files-2.11.3.so
7fc208e4a000-7fc208e4b000 r--p 0000b000 08:03 138808642                  /lib/libnss_files-2.11.3.so
7fc208e4b000-7fc208e4c000 rw-p 0000c000 08:03 138808642                  /lib/libnss_files-2.11.3.so
7fc208e4c000-7fc208e5f000 r-xp 00000000 08:03 138808640                  /lib/libresolv-2.11.3.so
7fc208e5f000-7fc20905e000 ---p 00013000 08:03 138808640                  /lib/libresolv-2.11.3.so
7fc20905e000-7fc20905f000 r--p 00012000 08:03 138808640                  /lib/libresolv-2.11.3.so
7fc20905f000-7fc209060000 rw-p 00013000 08:03 138808640                  /lib/libresolv-2.11.3.so
7fc209060000-7fc209062000 rw-p 00000000 00:00 0 
7fc209062000-7fc209064000 r-xp 00000000 08:03 138805439                  /lib/libkeyutils.so.1.3
7fc209064000-7fc209263000 ---p 00002000 08:03 138805439                  /lib/libkeyutils.so.1.3
7fc209263000-7fc209264000 rw-p 00001000 08:03 138805439                  /lib/libkeyutils.so.1.3
7fc209264000-7fc20926b000 r-xp 00000000 08:03 194524481                  /usr/lib/libkrb5support.so.0.1
7fc20926b000-7fc20946b000 ---p 00007000 08:03 194524481                  /usr/lib/libkrb5support.so.0.1
7fc20946b000-7fc20946c000 rw-p 00007000 08:03 194524481                  /usr/lib/libkrb5support.so.0.1
7fc20946c000-7fc20946f000 r-xp 00000000 08:03 138805424                  /lib/libcom_err.so.2.1
7fc20946f000-7fc20966e000 ---p 00003000 08:03 138805424                  /lib/libcom_err.so.2.1
7fc20966e000-7fc20966f000 rw-p 00002000 08:03 138805424                  /lib/libcom_err.so.2.1
7fc20966f000-7fc209694000 r-xp 00000000 08:03 194524416                  /usr/lib/libk5crypto.so.3.1
7fc209694000-7fc209893000 ---p 00025000 08:03 194524416                  /usr/lib/libk5crypto.so.3.1
7fc209893000-7fc209895000 rw-p 00024000 08:03 194524416                  /usr/lib/libk5crypto.so.3.1
7fc209895000-7fc2099ed000 r-xp 00000000 08:03 138808626                  /lib/libc-2.11.3.so
7fc2099ed000-7fc209bed000 ---p 00158000 08:03 138808626                  /lib/libc-2.11.3.so
7fc209bed000-7fc209bf1000 r--p 00158000 08:03 138808626                  /lib/libc-2.11.3.so
7fc209bf1000-7fc209bf2000 rw-p 0015c000 08:03 138808626                  /lib/libc-2.11.3.so
7fc209bf2000-7fc209bf7000 rw-p 00000000 00:00 0 
7fc209bf7000-7fc209c0d000 r-xp 00000000 08:03 138805431                  /lib/libgcc_s.so.1
7fc209c0d000-7fc209e0c000 ---p 00016000 08:03 138805431                  /lib/libgcc_s.so.1
7fc209e0c000-7fc209e0d000 rw-p 00015000 08:03 138805431                  /lib/libgcc_s.so.1
7fc209e0d000-7fc209e14000 r-xp 00000000 08:03 138808638                  /lib/librt-2.11.3.so
7fc209e14000-7fc20a013000 ---p 00007000 08:03 138808638                  /lib/librt-2.11.3.so
7fc20a013000-7fc20a014000 r--p 00006000 08:03 138808638                  /lib/librt-2.11.3.so
7fc20a014000-7fc20a015000 rw-p 00007000 08:03 138808638                  /lib/librt-2.11.3.so
7fc20a015000-7fc20a02c000 r-xp 00000000 08:03 194524846                  /usr/lib/libz.so.1.2.3.4
7fc20a02c000-7fc20a22b000 ---p 00017000 08:03 194524846                  /usr/lib/libz.so.1.2.3.4
7fc20a22b000-7fc20a22c000 rw-p 00016000 08:03 194524846                  /usr/lib/libz.so.1.2.3.4
7fc20a22c000-7fc20a2ac000 r-xp 00000000 08:03 138808643                  /lib/libm-2.11.3.so
7fc20a2ac000-7fc20a4ac000 ---p 00080000 08:03 138808643                  /lib/libm-2.11.3.so
7fc20a4ac000-7fc20a4ad000 r--p 00080000 08:03 138808643                  /lib/libm-2.11.3.so
7fc20a4ad000-7fc20a4ae000 rw-p 00081000 08:03 138808643                  /lib/libm-2.11.3.so
7fc20a4ae000-7fc20a4c5000 r-xp 00000000 08:03 138808631                  /lib/libpthread-2.11.3.so
7fc20a4c5000-7fc20a6c4000 ---p 00017000 08:03 138808631                  /lib/libpthread-2.11.3.so
7fc20a6c4000-7fc20a6c5000 r--p 00016000 08:03 138808631                  /lib/libpthread-2.11.3.so
7fc20a6c5000-7fc20a6c6000 rw-p 00017000 08:03 138808631                  /lib/libpthread-2.11.3.so
7fc20a6c6000-7fc20a6ca000 rw-p 00000000 00:00 0 
7fc20a6ca000-7fc20a6cc000 r-xp 00000000 08:03 138808647                  /lib/libdl-2.11.3.so
7fc20a6cc000-7fc20a8cc000 ---p 00002000 08:03 138808647                  /lib/libdl-2.11.3.so
7fc20a8cc000-7fc20a8cd000 r--p 00002000 08:03 138808647                  /lib/libdl-2.11.3.so
7fc20a8cd000-7fc20a8ce000 rw-p 00003000 08:03 138808647                  /lib/libdl-2.11.3.so
7fc20a8ce000-7fc20a98c000 r-xp 00000000 08:03 194524480                  /usr/lib/libkrb5.so.3.3
7fc20a98c000-7fc20ab8b000 ---p 000be000 08:03 194524480                  /usr/lib/libkrb5.so.3.3
7fc20ab8b000-7fc20ab96000 rw-p 000bd000 08:03 194524480                  /usr/lib/libkrb5.so.3.3
7fc20ab96000-7fc20abb4000 r-xp 00000000 08:03 138808628                  /lib/ld-2.11.3.so
7fc20ad5c000-7fc20ad91000 r--s 00000000 08:03 230034915                  /var/cache/nscd/services
7fc20ad91000-7fc20ad99000 rw-p 00000000 00:00 0 
7fc20adb1000-7fc20adb3000 rw-p 00000000 00:00 0 
7fc20adb3000-7fc20adb4000 r--p 0001d000 08:03 138808628                  /lib/ld-2.11.3.so
7fc20adb4000-7fc20adb5000 rw-p 0001e000 08:03 138808628                  /lib/ld-2.11.3.so
7fc20adb5000-7fc20adb6000 rw-p 00000000 00:00 0 
7fff0da9e000-7fff0dab3000 rw-p 00000000 00:00 0                          [stack]
7fff0dbff000-7fff0dc00000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
renecannao commented 9 years ago

I will soon look into it to solve the crash, but with the current implementation of the connection pool the session variables can get lost.

renecannao commented 9 years ago

Hi, so far I am not able to reproduce the issue. Here is an extract of traffic as captured by tcpdump : http://tinyurl.com/oh9srxd You can see that the SET command is correctly forwarded from the client to proxysql and from this one to mysqld, and the OK packet is forwarded from mysqld to the client. Perhaps it is a problem strictly related to the client libraries it is compiled against. What version of Debian/Ubuntu are you using?

Ithariel commented 9 years ago

Its a Debian Squeeze x64:

libmysqlclient16 5.1.73-1+deb6u1 mysql-client-5.1 5.1.73-1 php5-mysql 5.3.29-1~dotdeb.0