Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the MongoDB CPAN distribution.

Maintainer(s)' notes

Please don't report bugs here. Please use the MongoDB Perl driver issue tracker instead.

Report information
The Basics
Id: 63955
Status: resolved
Priority: 0/
Queue: MongoDB

People
Owner: Nobody in particular
Requestors: nwtour [...] mail.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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 +++
Subject: Re: [rt.cpan.org #63955] AutoReply: auto_reconnect not working
Date: Fri, 24 Dec 2010 00:26:43 +0300
To: bug-MongoDB [...] rt.cpan.org
From: nwtour <nwtour [...] mail.ru>
15.12.2010 20:53, Bugs in MongoDB via RT пишет: Show quoted text
> Greetings, >
My workaround: $cat test.pl use MongoDB; use File::Slurp qw(read_file); my $c = MongoDB::Connection->new(host => 'localhost', port => 27017)->foo->bar; my $i = 0; $SIG{PIPE} = sub { print "SIGPIPE :(\n"; exit; }; while(1) { if( $i > 3 and $i < 5 ) { my $pid = read_file('/data/db/mongod.lock'); print `sudo kill -HUP $pid`; } sleep 3; $i++; my ( $id, $data ); eval { $id = $c->insert({ some => 'data' }); $data = $c->find_one({ _id => $id }); }; if( $@ ) { print "Reconnect on $@\n"; $c = MongoDB::Connection->new(host => 'localhost', port => 27017)->foo->bar; } print $i, " ", $data, "\n"; } $perl test.pl 1 HASH(0x84e28e8) 2 HASH(0x851a630) 3 HASH(0x8285400) 4 HASH(0x82817a8) SIGPIPE :( $ patch mongo_link.c < correct_end_on_disconnect.patch patching file mongo_link.c $perl test.pl 1 HASH(0x84e28e8) 2 HASH(0x851a630) 3 HASH(0x8285400) 4 HASH(0x82817a8) Reconnect on can't get db response, not connected at /usr/local/lib/perl/5.12.2/MongoDB/Cursor.pm line 234. 5 6 HASH(0x8281698) 7 HASH(0x8281928) 8 HASH(0x8281618) ...

Message body is not shown because sender requested not to inline it.

Think this is a bug in find_one rather that auto_reconnect. Forked on github, added a test_case and requested pull: https://github.com/leejo/mongo-perl-driver/blob/f45687449f633f527b34616830b7db5d066fc371/t/auto_reconnect.t Output (MongoDB v0.42), after reconnect the find_one bombs out: *[154] >prove -v -Iinc -Iblib/lib -Iblib/arch t/auto_reconnect.t t/auto_reconnect.t .. forked process: 23570 all output going to: /tmp/mongod.log 1..7 ok 1 - The object isa MongoDB::Connection ok 2 - get_database, initial connection isa MongoDB::Database ok 3 - foo collection, initial connection isa MongoDB::Collection ok 4 - 4d8627b5c2488a0e5c000000 inserted (find) ok 5 - 4d8627b5c2488a0e5c000000 inserted (find_one) forked process: 23583 all output going to: /tmp/mongod.log ok 6 - 4d8627cbc2488a0e5c000001 inserted (find) Failed 1/7 subtests Test Summary Report ------------------- t/auto_reconnect.t (Wstat: 13 Tests: 6 Failed: 0) Non-zero wait status: 13 Parse errors: Bad plan. You planned 7 tests but ran 6. Files=1, Tests=6, 27 wallclock secs ( 0.01 usr 0.06 sys + 0.20 cusr 0.23 csys = 0.50 CPU) Result: FAIL
This issue has been migrated to the official JIRA issue tracker as https://jira.mongodb.org/browse/PERL-334