diff --git a/html/inc/util_ops.inc b/html/inc/util_ops.inc index 339f36f483..55d48faff6 100644 --- a/html/inc/util_ops.inc +++ b/html/inc/util_ops.inc @@ -244,16 +244,14 @@ function test_mysql_query($msg) { // - for any results w/ server state UNSENT, set server state to OVER // - set the CANCELLED bit in workunit.error_mask // -function cancel_wu($wuid1, $wuid2) { - $command1="update result set server_state=5, outcome=5 where server_state=2 and $wuid1<=workunitid and workunitid<=$wuid2"; - $command2="update workunit set error_mask=error_mask|16 where $wuid1<=id and id<=$wuid2"; - - if (!mysql_query($command1)) { - echo "MySQL command $command1 failed:
unable to cancel unsent results.
"; - return 1; - } else if (!mysql_query($command2)) { - echo "MySQL command $command2 failed:
unable to cancel workunits.
"; - return 2; +function cancel_wus($wuid1, $wuid2) { + $query="update result set server_state=5, outcome=5 where server_state=2 and $wuid1<=workunitid and workunitid<=$wuid2"; + if (!mysql_query($query)) { + error_page("DB query $query failed"); + } + $query="update workunit set error_mask=error_mask|16 where $wuid1<=id and id<=$wuid2"; + if (!mysql_query($query)) { + error_page("DB query $query failed"); } // trigger the transitioner (it will set file_delete_state) @@ -261,20 +259,26 @@ function cancel_wu($wuid1, $wuid2) { $now = time(); $query="update workunit set transition_time=$now where $wuid1<=id and id<=$wuid2"; mysql_query($query); - return 0; } // like above, but if a workunit has a result that's already sent, -// don't cancel it +// don't cancel the workunit // -function cancel_wu_if_unsent($id1, $id2) { +function cancel_wus_if_unsent($id1, $id2) { $wus = BoincWorkunit::enum("id >= $id1 and id <= $id2"); foreach ($wus as $wu) { $results = BoincResult::enum("workunitid=$wu.id and server_state > 2"); if (count($results)) continue; - + $query="update result set server_state=5, outcome=5 where workunitid=$wu->id"; + if (!mysql_query($query)) { + error_page("DB query $query failed"); + } + if (!$wu->update("error_mask=error_mask|16")) { + error_page("WU update failed"); + } } + return 0; } if (isset($cli_only)) { diff --git a/html/ops/cancel_wu_action.php b/html/ops/cancel_wu_action.php index 56ee8a1f94..e9264637de 100644 --- a/html/ops/cancel_wu_action.php +++ b/html/ops/cancel_wu_action.php @@ -24,31 +24,27 @@ require_once("../inc/db.inc"); require_once("../inc/util_ops.inc"); -admin_page_head("Cancel WU"); - db_init(); $wuid1 = get_int('wuid1'); $wuid2 = get_int('wuid2'); +$unsent_only = get_str('unsent_only', true); if ($wuid1<1 || $wuid2<$wuid1) { - echo "

Workunit IDs fail to satisfy the conditions:
- 1 <= WU1 ($wuid1) <= WU2 ($wuid2)
- Unable to process request to cancel workunits. -

- "; - exit(); + error_page( + "

Workunit IDs fail to satisfy the conditions:

0 < ID1 <= ID2" + ); } -echo "CANCELLING workunits $wuid1 to $wuid2 inclusive....
"; - -if (cancel_wu($wuid1, $wuid2)) { - echo "

Failed in"; +if ($unsent_only) { + cancel_wus_if_unsent($wuid1, $wuid2); } else { - echo "

Success in"; + cancel_wus($wuid1, $wuid2); } -echo " cancelling workunits $wuid1 <= WUID <= $wuid2

"; +admin_page_head("Cancel jobs"); +echo " canceled jobs with $wuid1 <= workunit ID <= $wuid2"; admin_page_tail(); + $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit ?> diff --git a/html/ops/cancel_wu_form.php b/html/ops/cancel_wu_form.php index cb8e20f6dc..72b00ae3ad 100644 --- a/html/ops/cancel_wu_form.php +++ b/html/ops/cancel_wu_form.php @@ -20,20 +20,16 @@ require_once("../inc/util_ops.inc"); -admin_page_head("Cancel workunit(s)"); +admin_page_head("Cancel jobs"); echo "
"; echo "

- This form may be used to cancel unnecessary or unwanted workunits. - We recommend that you stop the project before doing this. - Note that the workunits and their corresponding - results (if any) are NOT removed from the database. + We recommend that you stop the project before canceling jobs. +

+ Canceled jobs are not removed from the database. Instead, they are marked as 'no longer needed'. - In most cases you should probably only remove workunits whose results - are all unsent, - since otherwise a user will not get credit - for a result that they might return. +

"; // TODO: David, a query that shows all workunits that do not have all results unsent is: @@ -42,9 +38,18 @@ echo "

// be useful to incorporate into this page. start_table(); -row2("First Workunit (ID) to cancel", ""); +row2("Workunit ID of first job to cancel", " + You can cancel jobs with instances that are in progress, + but if you do so, users will not get credit for these instances. + + ", + "" +); +row2("", ""); end_table(); echo "

diff --git a/html/ops/cancel_wus.php b/html/ops/cancel_wus.php index b1a422383b..821255f997 100644 --- a/html/ops/cancel_wus.php +++ b/html/ops/cancel_wus.php @@ -7,5 +7,5 @@ require_once("../inc/util_ops.inc"); db_init(); -//cancel_wu(0, 636); +//cancel_wus(0, 636); ?>