Ruby client: Patch to fix issues with unnecessary connections being created

46 views
Skip to first unread message

Martyn Loughran

unread,
Oct 21, 2009, 9:41:20 AM10/21/09
to beansta...@googlegroups.com
Hi all,

I made some changes to the beanstalk-client library to solve problems
with unnecessary connections being created, and connections being left
open. This was causing hard to replicate, but recurring errors in
beanstalk:

beanstalkd: prot.c:1612 in h_accept: accept(): Too many open files
beanstalkd: net.c:74 in brake: too many connections; putting on the brakes

For example following code would create and leave open 5 connections
to beanstalkd

require 'beanstalk-client'

pool = Beanstalk::Pool.new('localhost:11300')

5.times {
pool.reserve(0) rescue Beanstalk::TimedOut
}

loop {}

which you can check with `lsof -i TCP:11300`.

The patched code will, in the example above, create a single
connection and reuse it for all reserve calls.

http://github.com/mloughran/beanstalk-client-ruby

Regards,

Martyn

P.S. Is there a plan to move the official repository to github now
that the beanstalkd server code has moved?

Reply all
Reply to author
Forward
0 new messages