Changeset 824

Show
Ignore:
Timestamp:
02/08/02 20:08:44 (11 years ago)
Author:
bradfitz
Message:

make this robust against dbs being restarted.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/bin/qbufferd.pl

    r752 r824  
    6666    # do main cluster updates 
    6767    my $dbh = LJ::get_dbh("master"); 
    68     my $sth = $dbh->prepare("SELECT tablename, COUNT(*) FROM querybuffer GROUP BY 1"); 
    69     $sth->execute; 
    70     my @tables; 
    71     while (my ($table, $count) = $sth->fetchrow_array) { 
    72         push @tables, $table; 
     68    if ($dbh) { 
     69        my $sth = $dbh->prepare("SELECT tablename, COUNT(*) FROM querybuffer GROUP BY 1"); 
     70        $sth->execute; 
     71        my @tables; 
     72        while (my ($table, $count) = $sth->fetchrow_array) { 
     73            push @tables, $table; 
     74        } 
     75        foreach my $table (@tables) { 
     76            my $count = LJ::query_buffer_flush($dbh, $table); 
     77        } 
    7378    } 
    74     foreach my $table (@tables) { 
    75         my $count = LJ::query_buffer_flush($dbh, $table); 
    76     } 
    77  
     79         
    7880    # handle clusters 
    7981    foreach my $c (@LJ::CLUSTERS) { 
    8082        my $db = LJ::get_cluster_master($c); 
     83        next unless $db; 
    8184 
    8285        my $sth = $db->prepare("SELECT cmd, COUNT(*) FROM cmdbuffer GROUP BY 1");