IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 1, 2009, 5:21:32 PM (17 years ago)
Author:
jhoblitt
Message:

add the ability to delete a storage object when it has instances that are offline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r24607 r24637  
    5656    my ($config) = @_;
    5757
    58     # log4perl is not avaliable until we call init()
     58    # log4perl is not available until we call init()
    5959    Nebulous::Server::Log->init($config);
    6060    my $log = Log::Log4perl::get_logger( "Nebulous::Server" );
     
    16221622TRANS: while (1) {
    16231623        eval {
    1624             my $instances;
     1624            my $total;
     1625            my $available;
    16251626            my $so_id;
    16261627            my $ins_id;
     
    16361637                my $record = $query->fetchrow_hashref;
    16371638                $so_id      = $record->{ 'so_id' };
    1638                 $instances  = $record->{ 'count(ins_id)' };
     1639                $total      = $record->{ 'total' };
     1640                $available  = $record->{ 'available' };
    16391641                $query->finish;
    16401642            }
     
    16641666                    die( "affected row count is $rows instead of 1" );
    16651667                }
    1666             }
    1667 
    1668             # if we just deleted the last instance associated with a storage object
    1669             # remove it too
    1670             if ( $instances == 1 ) {
     1668               
     1669            }
     1670
     1671            # if we just deleted the last 'available' instance associated with
     1672            # a storage object remove it too
     1673            if ( $available == 1 ) {
    16711674                # remove key from cache
    16721675                $self->cache->delete($key->path) if defined $self->cache;
    16731676
    1674                 # we just removed the last instance
     1677                # record the path of the innaccesible files for deferred
     1678                # deletion
     1679                {
     1680                    my $query = $db->prepare_cached( $sql->copy_instances_to_deleted );
     1681                    $query->execute( $so_id );
     1682                }
     1683                # remove all instances... not strictly nessicary as the delete
     1684                # from storage_object should cascade but the fkey was specified
     1685                # without the cascade
     1686                {
     1687                    my $query = $db->prepare_cached( $sql->delete_instance_by_so_id );
     1688                    $query->execute( $so_id );
     1689                }
     1690               
     1691                # delete the storage object, remaining instances should be
     1692                # removed via cascading delete
    16751693                my $query = $db->prepare_cached( $sql->delete_object );
    16761694                my $rows = $query->execute( $so_id );
Note: See TracChangeset for help on using the changeset viewer.