[Dirvish] Dirvish expiring newer images

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Thu Sep 25 15:00:22 UTC 2008


Loren M. Lang wrote:
> I have an old backup drive that I just put back into the rotation.  It
> had some old images that are all now expired.  Since the vaults still
> use the same configuration, I decided to just run dirvish-expire
> followed by dirvish-runall and was surprised to see that dirvish-expire
> expired all but the oldest good image.  I have no reason to believe that
> at least some of the newer images had completed successfully.  It looks
> like dirvish-expire does not expire images in the right order when all
> images have expired.
> 
> # dirvish-expire; dirvish-runall
> cannot expire server:default:20080423 No unexpired good images
> server:default 20080424 2008-04-24 02:04  +28 days == 2008-05-22 02:03
> server:default 20080425 2008-04-25 01:25  +28 days == 2008-05-23 01:24
> server:default 20080426 2008-04-26 01:25  +28 days == 2008-05-24 01:25
> server:default 20080427 2008-04-27 01:25  +28 days == 2008-05-25 01:24
> ...
> # ls server
> 20080423  20080925  dirvish

Looking at the code, I tend to agree. It appears to sort in increasing
order of date - as confirmed by Loren's output - but it treats the first
one as special - again as confirmed by Loren's output. Especially
interesting are the *two* warnings about the sort order!

I haven't done any testing but at first glance this does look like a bug
to me.

Cheers, Dave

for $expire (sort(imsort @expires))
{
        my ($created, $expired);
        ($created = $$expire{created}) =~ s/:\d\d$//;
        ($expired = $$expire{expire}) =~ s/:\d\d$//;

        if (!$unexpired{$$expire{vault}}{$$expire{branch}})
        {
                printf "cannot expire %s:%s:%s No unexpired good images\n",
                        $$expire{vault},
                        $$expire{branch},
                        $$expire{image};
                $$expire{status} =~ /^success/
                        and ++$unexpired{$$expire{vault}}{$$expire{branch}};
                # By virtue of the sort order this will be the newest
                # image so that older ones can be expired.
                next;
        }
        $$Options{quiet} or printf "%-15s %-15s %-16.16s  %s\n",
                $$expire{vault} . ':' .  $$expire{branch},
                $$expire{image},
                $created,
                $expired;

        $$Options{'no-run'} and next;

        system("rm -rf $$expire{path}/tree");
        $$Options{tree} and next;

        system("rm -rf $$expire{path}");
}

...

## WARNING:  don't mess with the sort order, it is needed so that if
## WARNING:  all images are expired the newest will be retained.
sub imsort
{
        $$a{vault} cmp $$b{vault}
        || $$a{branch} cmp $$b{branch}
        || $$a{created} cmp $$b{created};
}


More information about the Dirvish mailing list