Changeset 359

Show
Ignore:
Timestamp:
08/21/06 21:07:08 (2 years ago)
Author:
marksmith
Message:

* per Brad, never let fsck table get above 10,000 items. this is to prevent

runaway situations if the checker fails and we get more files we don't want
the table to grow to every file available.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/server-newrepl/lib/MogileFS/Worker/Checker.pm

    r358 r359  
    6565        # into the database to work on next 
    6666        my $highest_fid = Mgd::get_server_setting('fsck_highest_fid_checked') || 0; 
     67        my $total_already = $dbh->selectrow_array('SELECT COUNT(*) FROM fsck') || 0; 
     68        my $limit = 10_000 - $total_already;  # but only up to $limit items 
    6769 
    68         # now extract some files and re-insert them 
    69         $dbh->do(qq{ 
    70             INSERT INTO fsck (fid, nextcheck) 
    71                 SELECT fid, 0 FROM file WHERE fid > ? ORDER BY fid LIMIT 1000 
    72         }, undef, $highest_fid); 
     70        # now extract some files and re-insert them, but only if we need more 
     71        if ($limit > 0) { 
     72            $dbh->do(qq{ 
     73                INSERT INTO fsck (fid, nextcheck) 
     74                    SELECT fid, 0 FROM file WHERE fid > ? ORDER BY fid LIMIT $limit 
     75            }, undef, $highest_fid); 
    7376 
    74         # toss an error if we had one, but don't exit because we want to do the next block 
    75         # regardless.  that ensures that if we do get an error such as duplicate key because 
    76         # of the following race condition, we only see it once. 
    77         error("database error fetching new rows: " . $dbh->errstr) if $dbh->err; 
     77            # toss an error if we had one, but don't exit because we want to do the next block 
     78            # regardless.  that ensures that if we do get an error such as duplicate key because 
     79            # of the following race condition, we only see it once. 
     80            error("database error fetching new rows: " . $dbh->errstr) if $dbh->err; 
    7881 
    79         # this is a bit racy, but it doesn't matter since it's kinda irrelevant what the 
    80         # value gets set to.  this is an optimization, so we just try to get it mostly right. 
    81         my $highest = $dbh->selectrow_array('SELECT MAX(fid) FROM fsck'); 
    82         Mgd::set_server_setting('fsck_highest_fid_checked', $highest||0); 
     82            # this is a bit racy, but it doesn't matter since it's kinda irrelevant what the 
     83            # value gets set to.  this is an optimization, so we just try to get it mostly right. 
     84            my $highest = $dbh->selectrow_array('SELECT MAX(fid) FROM fsck'); 
     85            Mgd::set_server_setting('fsck_highest_fid_checked', $highest||0); 
     86        } 
    8387    }); 
    8488}