couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Macdonald <macfisher...@gmail.com>
Subject Re: all_dbs_active - what should an app do when it gets this?
Date Wed, 25 Nov 2009 18:02:07 GMT
On Mon, Nov 23, 2009 at 8:26 PM, Jeff Macdonald <macfisherman@gmail.com> wrote:
> On Mon, Nov 23, 2009 at 6:41 PM, Damien Katz <damien@apache.org> wrote:
>> If you are hitting the limit, but don't have enough clients accessing the
>> dbs, and have no views being built and no compactions happening, it might be
>> bug in CouchDB.
>
> I have 1 client program using Net::CouchDB, no views yet, no
> compactions. I'll try to create a small test program tomorrow to see
> if I can duplicate the conditions.

This code can reproduce what I'm seeing:

#!/usr/bin/perl

use FindBin qw($Bin);
use lib ("$Bin/lib","$Bin/cpan-lib");

use Net::CouchDB;

my $host=shift;
my $secs=shift;

my $couch=Net::CouchDB->new($host);

my @docs=map{ { '_id' => $_, 'lang' => 'erlang' } } (1...500);

foreach (1...200) {
	my $dbh=$couch->create_db("event-$_");
	print "Created database $_\n";
	$dbh->insert(@docs);
	sleep($secs);
}


Net::CouchDB is done by Michael Hendricks  <michael@ndrix.org>.

Running the code like so reproduces the error:

$ ./test-active-dbs http://localhost:5984 0
<output trimmed>
Created database 100
Unknown status code '500' while trying to create a database named
'event-101'. PUT request to http://localhost:5984/event-101/:
all_dbs_active

Using 1 for sleep resulted in the same results. Using 2 for sleep
resulted in this:
Created database 33
Unknown status code '500' while trying to create a database named
'event-34'. PUT request to http://localhost:5984/event-34/:
{gen_server,call,
            [couch_server,
             {create,<<"event-34">>,
                     [{user_ctx,{user_ctx,null,[<<"_admin">>]}}]}]}

log output is:
[info] [<0.4631.0>] 127.0.0.1 - - 'POST' /event-33/_bulk_docs 201
[error] [<0.4631.0>] Uncaught error in HTTP request: {exit,
                                 {timeout,
                                  {gen_server,call,
                                   [couch_server,
                                    {create,<<"event-34">>,
                                     [{user_ctx,
                                       {user_ctx,null,[<<"_admin">>]}}]}]}}}
[info] [<0.4631.0>] Stacktrace: [{gen_server,call,2},
             {couch_server,create,2},
             {couch_httpd_db,create_db_req,2},
             {couch_httpd,handle_request,5},
             {mochiweb_http,headers,5},
             {proc_lib,init_p_do_apply,3}]
[info] [<0.4631.0>] 127.0.0.1 - - 'PUT' /event-34/ 500


(I was looking at futon around the time this crash happened)

Running with 2 secs a 2nd time, the error happened when creating database 27. :(

I delete the DBs using this code:

$ more delete-dbs
#!/usr/bin/perl

use FindBin qw($Bin);
use lib ("$Bin/lib","$Bin/cpan-lib");

use Net::CouchDB;

use Data::Dumper;

my $host=shift;

my $couch=Net::CouchDB->new($host);
my @dbs=$couch->all_dbs();

foreach my $db (@dbs) {
	if($db->name()=~/^event-/) {
		$db->delete();
	}
}

Doing a ls in var shows the DBs are gone. Actually, I don't think the
error in these cases is couchdb's fault. I noticed the system
hesitating. I've seen this with my editor as well when saving files.
Not sure what is wrong with the system in that case.

In any case, changing sleep to 2,5 or 10 secs resulted in
all_dbs_active when it got to the 101st database.

I also tried this variation and got the same results when sec=0
(didn't try any other values). The thinking was maybe a need to create
a new session for couchdb to release something.

#!/usr/bin/perl

use FindBin qw($Bin);
use lib ("$Bin/lib","$Bin/cpan-lib");

use Net::CouchDB;

my $host=shift;
my $secs=shift;

my @docs=map{ { '_id' => $_, 'lang' => 'erlang' } } (1...500);

foreach my $i (1...10) {
	my $couch=Net::CouchDB->new($host);
	foreach my $j (1...20) {
		my $dbh=$couch->create_db("event-$i-$j");
		print "Created database event-$i-$j\n";
		$dbh->insert(@docs);
		sleep($secs);
	}
}

Finally, I notice futon has problems when there are > 100 dbs. I'm
guessing when futon get stats regarding each DB on the overview page,
that causes each database to be active. That seems like a simple way
to create a service denial for other clients just by using futon.

Anyhow, for now I'm upping my database limit. I don't know of this is
a serious problem or not, but something doesn't seem right to me.

TIA


-- 
Jeff Macdonald
Ayer, MA

Mime
View raw message