Too many rows in file_on

Andreas J. Koenig andreas.koenig.gmwojprw at franz.ak.mind.de
Thu Dec 7 03:37:10 UTC 2006


I'm running with rev. 518 now and I encounter no apparent
misbehaviour, that's very nice. But I have the impression we need to
clean up a bit.

>From 'show table status' I get these figures:

| file                 | 61672   |
| file_on              | 1197622 |

Given that all my classes have a mindevcount of 2, this seems like the
result of a bug that hit us some day, correct?

Needless to say that plenty of records exist for which there is a
file_on record but no file record.

Is this perl script suited for cleaning up or are there nicer ways?

  my $sth = $dbh->prepare("select fo.fid from file_on fo left join file fi using (fid) where dkey is NULL limit 1024");
  my $sth2 = $dbh->prepare("delete from file_on where fid = ?");
  my $sth3 = $dbh->prepare("select count(*) from file_on");
  while (){
    $sth3->execute;
    my($cnt) = $sth3->fetchrow_array or last;
    $sth->execute;
    my($mfid);
    while (my($fid) = $sth->fetchrow_array){
      $sth2->execute($fid);
      $mfid = $fid;
    }
    last unless $mfid;
    print "$mfid ($cnt)\n";
    sleep 1;
  }

Are there other cleanup tasks I should go after?

Thanks,
-- 
andreas


More information about the mogilefs mailing list