backburner
backburner copied to clipboard
Backburner::Worker#retry_connection! does not close connections before creating new ones
Backburner::Worker#retry_connection! does not call close, leaving open connections to servers until the process holding those connections is killed.
Can be reproduced by starting 2 servers. Then, queue jobs in a loop.
require 'backburner'
Backburner.configure do |config|
config.beanstalk_url = ['beanstalk://127.0.0.1:11300', 'beanstalk://127.0.0.1:11301']
end
class Job
def self.perform(message)
p message
end
end
loop do
Backburner::Worker.enqueue(Job, ['Hello'])
end
In another process run the worker.
Backburner.work
Kill one of the servers. The other servers output will look like this.
$ beanstalkd -V -p 11300
pid 4318
bind 3 0.0.0.0:11300
accept 5
accept 6
accept 7
accept 8
accept 9
accept 10
accept 11
accept 12
accept 13
accept 14
accept 15
lsof of this process.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME [2/1880]
beanstalk 32480 vagrant cwd DIR 8,3 4096 261123 /home/vagrant
beanstalk 32480 vagrant rtd DIR 8,3 4096 2 /
beanstalk 32480 vagrant txt REG 8,3 63744 789844 /usr/bin/beanstalkd
beanstalk 32480 vagrant mem REG 8,3 156928 522458 /lib64/ld-2.12.so
beanstalk 32480 vagrant mem REG 8,3 1926800 522604 /lib64/libc-2.12.so
beanstalk 32480 vagrant 0u CHR 136,4 0t0 7 /dev/pts/4
beanstalk 32480 vagrant 1u CHR 136,4 0t0 7 /dev/pts/4
beanstalk 32480 vagrant 2u CHR 136,4 0t0 7 /dev/pts/4
beanstalk 32480 vagrant 3u IPv4 97801 0t0 TCP *:11300 (LISTEN)
beanstalk 32480 vagrant 4u REG 0,9 0 3780 [eventpoll]
beanstalk 32480 vagrant 5u IPv4 97810 0t0 TCP localhost:11300->localhost:55278 (ESTABLISHED)
beanstalk 32480 vagrant 6u IPv4 98268 0t0 TCP localhost:11300->localhost:55306 (ESTABLISHED)
beanstalk 32480 vagrant 7u IPv4 98274 0t0 TCP localhost:11300->localhost:55308 (ESTABLISHED)
beanstalk 32480 vagrant 8u IPv4 98279 0t0 TCP localhost:11300->localhost:55310 (ESTABLISHED)
beanstalk 32480 vagrant 9u IPv4 98284 0t0 TCP localhost:11300->localhost:55312 (ESTABLISHED)
beanstalk 32480 vagrant 10u IPv4 98291 0t0 TCP localhost:11300->localhost:55314 (ESTABLISHED)
beanstalk 32480 vagrant 11u IPv4 98296 0t0 TCP localhost:11300->localhost:55316 (ESTABLISHED)
beanstalk 32480 vagrant 12u IPv4 98301 0t0 TCP localhost:11300->localhost:55318 (ESTABLISHED)
beanstalk 32480 vagrant 13u IPv4 98306 0t0 TCP localhost:11300->localhost:55320 (ESTABLISHED)
beanstalk 32480 vagrant 14u IPv4 98311 0t0 TCP localhost:11300->localhost:55322 (ESTABLISHED)
beanstalk 32480 vagrant 16u IPv4 98236 0t0 TCP localhost:11300->localhost:55302 (ESTABLISHED)
beanstalk 32480 vagrant 17u IPv4 98252 0t0 TCP localhost:11300->localhost:55304 (ESTABLISHED)