mirror of https://github.com/BOINC/boinc.git
admin web: add option to Cancel Jobs page to cancel only unsent jobs
This commit is contained in:
parent
9eb232ab08
commit
e1523cc093
|
@ -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:<br/>unable to cancel unsent results.<br/>";
|
||||
return 1;
|
||||
} else if (!mysql_query($command2)) {
|
||||
echo "MySQL command $command2 failed:<br/>unable to cancel workunits.<br/>";
|
||||
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)) {
|
||||
|
|
|
@ -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 "<h2>Workunit IDs fail to satisfy the conditions:<br/>
|
||||
1 <= WU1 ($wuid1) <= WU2 ($wuid2)<br/>
|
||||
Unable to process request to cancel workunits.
|
||||
</h2>
|
||||
";
|
||||
exit();
|
||||
error_page(
|
||||
"<h2>Workunit IDs fail to satisfy the conditions:<p> 0 < ID1 <= ID2"
|
||||
);
|
||||
}
|
||||
|
||||
echo "CANCELLING workunits $wuid1 to $wuid2 inclusive....<br/>";
|
||||
|
||||
if (cancel_wu($wuid1, $wuid2)) {
|
||||
echo "<h2>Failed in";
|
||||
if ($unsent_only) {
|
||||
cancel_wus_if_unsent($wuid1, $wuid2);
|
||||
} else {
|
||||
echo "<h2>Success in";
|
||||
cancel_wus($wuid1, $wuid2);
|
||||
}
|
||||
echo " cancelling workunits $wuid1 <= WUID <= $wuid2</h2>";
|
||||
|
||||
admin_page_head("Cancel jobs");
|
||||
echo " canceled jobs with $wuid1 <= workunit ID <= $wuid2</h2>";
|
||||
admin_page_tail();
|
||||
|
||||
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
||||
?>
|
||||
|
|
|
@ -20,20 +20,16 @@
|
|||
|
||||
require_once("../inc/util_ops.inc");
|
||||
|
||||
admin_page_head("Cancel workunit(s)");
|
||||
admin_page_head("Cancel jobs");
|
||||
|
||||
echo "<form action=\"cancel_wu_action.php\">
|
||||
";
|
||||
echo "<p>
|
||||
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.
|
||||
<p>
|
||||
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.
|
||||
<p>
|
||||
<p>
|
||||
";
|
||||
// TODO: David, a query that shows all workunits that do not have all results unsent is:
|
||||
|
@ -42,9 +38,18 @@ echo "<p>
|
|||
// be useful to incorporate into this page.
|
||||
|
||||
start_table();
|
||||
row2("First Workunit (ID) to cancel", "<input size=\"32\" name=\"wuid1\"");
|
||||
row2("Last Workunit (ID) to cancel", "<input size=\"32\" name=\"wuid2\"");
|
||||
row2("", "<input type=\"submit\" value=\"CANCEL WORKUNITS\">");
|
||||
row2("Workunit ID of first job to cancel", "<input size=\"32\" name=\"wuid1\"");
|
||||
row2("Workunit ID of last job to cancel", "<input size=\"32\" name=\"wuid2\"");
|
||||
row2(
|
||||
"Cancel only jobs with no instance in progress
|
||||
<br><span class=note>
|
||||
You can cancel jobs with instances that are in progress,
|
||||
but if you do so, users will not get credit for these instances.
|
||||
</span>
|
||||
",
|
||||
"<input type=checkbox name=unsent_only>"
|
||||
);
|
||||
row2("", "<input type=\"submit\" value=\"Cancel jobs\">");
|
||||
end_table();
|
||||
echo "
|
||||
</form>
|
||||
|
|
|
@ -7,5 +7,5 @@ require_once("../inc/util_ops.inc");
|
|||
|
||||
db_init();
|
||||
|
||||
//cancel_wu(0, 636);
|
||||
//cancel_wus(0, 636);
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue