Changeset 24500
- Timestamp:
- Jun 18, 2009, 4:48:52 PM (17 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 3 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Server.pm (modified) (2 diffs)
-
lib/Nebulous/Server/SQL.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r24408 r24500 23 23 the semantics 24 24 - add nebdiskd mountpoint test retyring 25 - rework delete_instance() to avoid requiring an index on instance.uri 25 26 26 27 0.16 -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r24412 r24500 1581 1581 TRANS: while (1) { 1582 1582 eval { 1583 my $instances; 1583 1584 my $so_id; 1584 my $ins tances;1585 # get so_id1585 my $ins_id; 1586 # find so_id for key and get count of instances 1586 1587 { 1587 my $query = $db->prepare_cached( $sql->get_object_from_uri ); 1588 my $rows = $query->execute( $uri ); 1589 1588 my $query = $db->prepare_cached( $sql->get_instance_count_by_ext_id ); 1589 my $rows = $query->execute($key->path); 1590 1590 unless ( $rows > 0 ) { 1591 1591 $query->finish; 1592 die( "$key has no associated instances - this should not happen" ); 1593 } 1594 1595 my $record = $query->fetchrow_hashref; 1596 $so_id = $record->{ 'so_id' }; 1597 $instances = $record->{ 'count(ins_id)' }; 1598 $query->finish; 1599 } 1600 1601 # find ins_id for uri 1602 { 1603 my $query = $db->prepare_cached( $sql->get_instance_by_uri ); 1604 my $rows = $query->execute($so_id, $uri); 1605 unless ( $rows > 0) { 1606 $query->finish; 1592 1607 die( "no instance is associated with uri" ); 1593 1608 } 1594 1609 1595 $so_id = $query->fetchrow_hashref->{ 'so_id' }; 1596 $query->finish; 1597 1598 } 1599 1600 { 1601 my $query = $db->prepare_cached( $sql->get_instance_count ); 1602 $query->execute( $so_id ); 1603 1604 $instances = $query->fetchrow_hashref->{ 'count(ins_id)' }; 1610 $ins_id = $query->fetchrow_hashref->{ 'ins_id' }; 1605 1611 $query->finish; 1606 1612 } … … 1608 1614 # remove instance 1609 1615 { 1610 my $query = $db->prepare_cached( $sql->delete_instance );1611 my $rows = $query->execute( $ uri);1616 my $query = $db->prepare_cached( $sql->delete_instance_by_ins_id ); 1617 my $rows = $query->execute( $ins_id ); 1612 1618 $query->finish; 1613 1619 1614 # if we affected something other then two rows something very bad1615 # has happened1620 # if we affected something other then one row something very 1621 # bad has happened 1616 1622 unless ( $rows == 1 ) { 1617 1623 die( "affected row count is $rows instead of 1" ); -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r24423 r24500 175 175 WHERE ext_id = ? 176 176 }, 177 delete_instance => qq{177 delete_instance_by_ins_id => qq{ 178 178 DELETE FROM instance 179 WHERE uri= ?179 WHERE ins_id = ? 180 180 }, 181 181 get_object_from_uri => qq{ … … 184 184 WHERE uri = ? 185 185 }, 186 get_instance_by_uri => qq{ 187 SELECT ins_id 188 FROM instance 189 WHERE 190 so_id = ? 191 AND uri = ? 192 }, 186 193 get_instance_count => qq{ 187 194 SELECT count(ins_id) 188 195 FROM instance 189 196 WHERE so_id = ? 197 }, 198 get_instance_count_by_ext_id => qq{ 199 SELECT count(ins_id), so_id 200 FROM instance 201 JOIN storage_object 202 USING(so_id) 203 WHERE 204 ext_id = ? 205 GROUP BY so_id 190 206 }, 191 207 get_object_instances => qq{
Note:
See TracChangeset
for help on using the changeset viewer.
