Changeset 1130

Show
Ignore:
Timestamp:
11/14/07 11:55:09 (1 year ago)
Author:
ask
Message:

Fix the automatic retry on errors saving a chunk

(I had errors like that; then fixed the tool and now I can't reproduce
the errors to test the changes...)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/utils/Changes

    r1126 r1130  
     1  * Fix the automatic retry on errors saving a chunk (Ask Bjoern Hansen) 
     2 
    13  * Improve error messages from mogtool (Ask Bjoern Hansen). 
    24 
  • trunk/utils/mogtool

    r1126 r1130  
    800800        my $dkey = $opts{big} ? "$key,$chunknum" : "$key"; 
    801801 
    802         # TODO: be resilient to transient errors, retry, etc. 
    803802        my $start_time = [ gettimeofday() ]; 
    804803        my $try = 0; 
    805804        while (1) { 
    806805            $try++; 
    807             my $fh = $mogfs->new_file($dkey, $opts{class}, $bufsize); 
    808             unless (defined $fh) { 
    809                 error("WARNING: Unable to create new file '$dkey'."); 
    810                 printf "This was try #$try and it's been %.2f seconds since we first tried.  Retrying...\n", tv_interval($start_time); 
    811                 sleep 1; 
    812                 next; 
    813             } 
    814             $fh->print($chunkbuf{$cn}); 
    815             unless ($fh->close) { 
    816                 error("WARNING: Unable to save file '$dkey'."); 
     806            eval { 
     807                my $fh = $mogfs->new_file($dkey, $opts{class}, $bufsize); 
     808                unless (defined $fh) { 
     809                    die "Unable to create new file"; 
     810                } 
     811                $fh->print($chunkbuf{$cn}); 
     812                unless ($fh->close) { 
     813                    die "Close failed"; 
     814                } 
     815            }; 
     816            if (my $err = $@) { 
     817                error("WARNING: Unable to save file '$dkey': $err"); 
    817818                printf "This was try #$try and it's been %.2f seconds since we first tried.  Retrying...\n", tv_interval($start_time); 
    818819                sleep 1;