| 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); |
|---|
| 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; |
|---|
| 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 | } |
|---|