Ops: combine statements for better performance

No need to change the same rows in two statements.
This commit is contained in:
Christian Beer 2016-03-03 14:36:15 +01:00
parent ae5b283e1a
commit 407a2fce47
1 changed files with 7 additions and 12 deletions

View File

@ -360,27 +360,22 @@ if (!isset($skip_auth_ops) && array_key_exists("SERVER_PORT", $_SERVER)) {
function cancel_wus_where($clause) {
$q1 = "CREATE TEMPORARY TABLE tmp SELECT id FROM workunit WHERE $clause;";
$q2 = "UPDATE result SET server_state=5, outcome=5 WHERE server_state=2 AND workunitid in (SELECT id FROM tmp);";
$q3 = "UPDATE workunit SET error_mask=error_mask|16 WHERE id in (SELECT id FROM tmp);";
$q4 = "UPDATE workunit SET transition_time=0 WHERE id in (SELECT id FROM tmp);";
$q5 = "DROP TABLE tmp;";
$q3 = "UPDATE workunit SET error_mask=error_mask|16, transition_time=0 WHERE id in (SELECT id FROM tmp);";
$q4 = "DROP TABLE tmp;";
if (!_mysql_query($q1)) {
echo "MySQL command '$q1' failed:<br/>unable to create temporary WU id table.<br>\n";
return 1;
} else if (!_mysql_query($q2)) {
echo "MySQL command '$q2' failed:<br/>unable to cancel unsent results.<br>\n";
_mysql_query($q5);
_mysql_query($q4);
return 2;
} else if (!_mysql_query($q3)) {
echo "MySQL command '$q3' failed:<br/>unable to cancel workunits.<br>\n";
_mysql_query($q5);
echo "MySQL command '$q3' failed:<br/>unable to cancel workunits and trigger transitioner.<br>\n";
_mysql_query($q4);
return 3;
} else if (!_mysql_query($q4)) {
echo "MySQL command '$q4' failed:<br/>unable to trigger transitioner.<br>\n";
_mysql_query($q5);
return 4;
}
_mysql_query($q5);
}
_mysql_query($q4);
echo "Successfully canceled WUs WHERE '$clause'<br>\n";
return 0;
}