Author: arkurth
Date: Tue Jan 13 08:42:37 2009
New Revision: 734175

URL: http://svn.apache.org/viewvc?rev=734175&view=rev
Log:
VCL-49
Fixed a bug which could cause multiple state processes to be running at the 
same time for a reservation.  This should never happen.  inuse.pm was clearing 
all computerloadlog rows for the reservation when it began processing, 
including the entry matching computerloadstate = 'begin'. This entry is used by 
vcld to determine if any other reservation processes are running before forking 
a new one. This caused vcld to fork an image process when a user initiates 
imaging while an inuse process is running.

Extended utils.pm::delete_computerloadlog_reservation to allow you to specify 
the load state names which shouldn't be deleted by prepending a '!' to the load 
state name argument.

Modified the call to delete_computerloadlog_reservation in inuse.pm to specify 
that 'begin' entries should not be deleted.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm
    incubator/vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=734175&r1=734174&r2=734175&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/inuse.pm Tue Jan 13 08:42:37 2009
@@ -134,8 +134,8 @@
        # Check if this is an imaging request, causes process to exit if state 
or laststate = image
        $request_forimaging = $self->_check_imaging_request();
 
-       # Remove rows from computerloadlog for this reservation
-       if (delete_computerloadlog_reservation($reservation_id)) {
+       # Remove rows from computerloadlog for this reservation, don't remove 
the loadstate=begin row
+       if (delete_computerloadlog_reservation($reservation_id, '!begin')) {
                notify($ERRORS{'OK'}, 0, "rows removed from computerloadlog 
table for reservation $reservation_id");
        }
        else {

Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=734175&r1=734174&r2=734175&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Tue Jan 13 08:42:37 2009
@@ -8124,7 +8124,11 @@
 
  Parameters  : $reservation_id, optional loadstatename
  Returns     : 0 failed or 1 success
- Description : Deletes rows from the computerloadlog table
+ Description : Deletes rows from the computerloadlog table. A loadstatename
+               argument can be specified to limit the rows removed to a
+               certain loadstatename. To delete all rows except those
+               matching a certain loadstatename, begin the loadstatename
+               with a !.
 
 =cut
 
@@ -8142,7 +8146,9 @@
        my $sql_statement;
        # Check if loadstateid was specified
        # If so, only delete rows matching the loadstateid
-       if ($loadstatename) {
+       if ($loadstatename && $loadstatename !~ /^!/) {
+               notify($ERRORS{'DEBUG'}, 0, "removing computerloadlog entries 
matching loadstate = $loadstatename");
+               
                $sql_statement = "
                DELETE
                computerloadlog
@@ -8155,7 +8161,26 @@
                AND computerloadstate.loadstatename = \'$loadstatename\'
                ";
        }
+       elsif ($loadstatename) {
+               # Remove the first character of loadstatename, it is !
+               $loadstatename = substr($loadstatename, 1);
+               notify($ERRORS{'DEBUG'}, 0, "removing computerloadlog entries 
NOT matching loadstate = $loadstatename");
+               
+               $sql_statement = "
+               DELETE
+               computerloadlog
+               FROM
+               computerloadlog,
+               computerloadstate
+               WHERE
+               computerloadlog.reservationid = $reservation_id
+               AND computerloadlog.loadstateid = computerloadstate.id
+               AND computerloadstate.loadstatename != \'$loadstatename\'
+               ";
+       }
        else {
+               notify($ERRORS{'DEBUG'}, 0, "removing all computerloadlog 
entries for reservation");
+               
                $loadstatename = 'all';
                $sql_statement = "
                DELETE
@@ -8169,11 +8194,11 @@
 
        # Call the database execute subroutine
        if (database_execute($sql_statement)) {
-               notify($ERRORS{'OK'}, 0, "deleted rows from computerloadlog 
table where reservation id=$reservation_id, loadstatename=$loadstatename");
+               notify($ERRORS{'OK'}, 0, "deleted rows from computerloadlog for 
reservation id=$reservation_id");
                return 1;
        }
        else {
-               notify($ERRORS{'WARNING'}, 0, "unable to delete from 
computerloadlog table where reservation id=$reservation_id, 
loadstatename=$loadstatename");
+               notify($ERRORS{'WARNING'}, 0, "unable to delete from 
computerloadlog table for reservation id=$reservation_id");
                return 0;
        }
 } ## end sub delete_computerloadlog_reservation


Reply via email to