nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.83k stars 304 forks source link

webdis crash when redis max connection exceeded #23

Open fabware opened 13 years ago

fabware commented 13 years ago

Hi, Nicolas

webdis will crash when redis max connection exceeded. You may reproduce it with the following steps:

  1. set the redis max connection: maxclient=256
  2. ab -n 100000 -c 1 http://127.0.0.1:7379/PUBLISH/ch:hello/world
  3. ab -n 255 -c 1 http://127.0.0.1:7379/SUBSCRIBE/ch:hello
  4. ab -n 2 -c 1 http://127.0.0.1:7379/SUBSCRIBE/ch:hello ( webdis will crash)

webdis will crash, strace of the webdis process as following:

clock_gettime(CLOCK_MONOTONIC, {10141, 66579365}) = 0
accept(12, {sa_family=AF_INET, sin_port=htons(43283), sin_addr=inet_addr("192.168.60.66")}, [16]) = 299
write(6, "\0\276\1\254\252*\0\0", 8)    = 8
epoll_wait(13, {{EPOLLIN, {u32=12, u64=12}}}, 32, 4294967295) = 1
clock_gettime(CLOCK_MONOTONIC, {10141, 68061365}) = 0
accept(12, {sa_family=AF_INET, sin_port=htons(43284), sin_addr=inet_addr("192.168.60.66")}, [16]) = 300
write(8, "\220\277\1\254\252*\0\0", 8)  = 8
epoll_wait(13, {{EPOLLIN, {u32=12, u64=12}}}, 32, 4294967295) = 1
clock_gettime(CLOCK_MONOTONIC, {10141, 69825365}) = 0
accept(12, {sa_family=AF_INET, sin_port=htons(43285), sin_addr=inet_addr("192.168.60.66")}, [16]) = 303
write(10, "\0\303\1\254\252*\0\0", 8)   = 8
epoll_wait(13,  <unfinished ...>
+++ killed by SIGSEGV +++

Error reply is expected rather than crash.

nicolasff commented 13 years ago

Hi,

Thanks for reporting this issue. I'll have a look soon.

nicolasff commented 13 years ago

I haven't been able to reproduce this issue yet, but I wanted to add one thing: hiredis will keep a dictionary of channel name -> connection for pub/sub channels, so N connections to the a single channel should create less than N connections to Redis.

Webdis is already supposed to return a 503 Service Unavailable if Redis is unreachable.

I'll keep investigating...