Subject: | auto_reconnect not working |
Date: | Wed, 15 Dec 2010 20:53:25 +0300 |
To: | bug-MongoDB [...] rt.cpan.org |
From: | Кокарев Константин <nwtour [...] mail.ru> |
$ uname -a
Linux debian 2.6.32-5-686 #1 SMP Sat Oct 30 22:47:19 UTC 2010 i686 GNU/Linux
$ perl -v
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
(with 50 registered patches, see perl -V for more detail)
MongoDB 0.40
In documentation MongoDB::Connection:
auto_reconnect
Boolean indicating whether or not to reconnect if the connection is interrupted. Defaults to 1.
But it isnt work.
Step to reproduce:
First console:
$ mongod;mongod;mongod;mongod
Second console, run script (test.pl):
use MongoDB;
use Data::Dumper;
use File::Slurp qw(read_file);
my $connection = MongoDB::Connection->new(host => 'localhost', port => 27017, auto_reconnect => 1);
my $database = $connection->foo;
my $collection = $database->bar;
my $i = 0;
while(1) {
if( $i > 3 ) {
my $pid = read_file('/data/db/mongod.lock');
print `sudo kill -HUP $pid`;
}
sleep 3;
$i++;
my $id = $collection->insert({ some => 'data' });
my $data = $collection->find_one({ _id => $id });
print $i, " ", $data, "\n";
}
Out:
$ perl test.pl
1 HASH(0x901e738)
2 HASH(0x9019080)
3 HASH(0x8de9e80)
4 HASH(0x90189a0)
$
(End of output)
$ strace perl test.pl ended:
nanosleep({3, 0}, 0xbfaa0d24) = 0
time(NULL) = 1292435444
time(NULL) = 1292435444
send(3, "A\0\0\0\200\361\4\0\0\0\0\0\322\7\0\0\0\0\0\0foo.bar\0%\0\0\0"..., 65, 0) = 65
send(3, "?\0\0\0\201\361\4\0\0\0\0\0\324\7\0\0\0\0\0\0foo.bar\0\0\0\0\0"..., 63, 0) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
+++ killed by SIGPIPE +++