Skip to content

Commit

Permalink
don't crash as easily with bad slave settings
Browse files Browse the repository at this point in the history
(tomas doran)

git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1457 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information
dormando committed Jun 17, 2010
1 parent 38ec47c commit 2dda652
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* make it slightly harder to crash trackers with bad slave DB settings
(Tomas Doran)

* make tracker -> storage node connection timeout configurable.
was hardcoded to 2 seconds. (Tomas Doran)

Expand Down
14 changes: 12 additions & 2 deletions lib/MogileFS/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package MogileFS::Store;
use strict;
use warnings;
use Carp qw(croak);
use MogileFS::Util qw(throw max);
use MogileFS::Util qw(throw max error);
use DBI; # no reason a Store has to be DBI-based, but for now they all are.
use List::Util ();

Expand Down Expand Up @@ -186,8 +186,18 @@ sub _slaves_list {
my @ret;
foreach my $key (split /\s*,\s*/, $sk) {
my $slave = MogileFS::Config->server_setting("slave_$key");

if (!$slave) {
error("key for slave DB config: slave_$key not found in configuration");
next;
}

my ($dsn, $user, $pass) = split /\|/, $slave;
push @ret, [$dsn, $user, $pass];
if (!defined($dsn) or !defined($user) or !defined($pass)) {
error("key slave_$key contains $slave, which doesn't split in | into DSN|user|pass - ignoring");
next;
}
push @ret, [$dsn, $user, $pass]
}
$self->{slave_list_cache} = \@ret;
Expand Down

0 comments on commit 2dda652

Please sign in to comment.