From 5ad43a6509eb10a87de00edec54d3c2088bfb1b7 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 3 Apr 2015 20:00:13 -0700 Subject: [PATCH] validator: add --wu_id N option for debugging single WU --- db/boinc_db.cpp | 24 ++++++++++++++++++------ sched/validator.cpp | 12 ++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/db/boinc_db.cpp b/db/boinc_db.cpp index 4e3cfea3d5..5542f2789a 100644 --- a/db/boinc_db.cpp +++ b/db/boinc_db.cpp @@ -1750,15 +1750,27 @@ int DB_VALIDATOR_ITEM_SET::enumerate( ) { int retval; char query[MAX_QUERY_LEN], mod_clause[256]; + char main_clause[256]; MYSQL_ROW row; VALIDATOR_ITEM new_item; if (!cursor.active) { + sprintf(main_clause, + " and wu.appid = %d and wu.need_validate > 0 ", appid + ); if (wu_id_modulus) { - sprintf(mod_clause, - " and wu.id %% %d = %d ", - wu_id_modulus, wu_id_remainder - ); + // terrible kludge: if rem >= mod, treat it as a WU ID + // This is to support the --wu_id debugging feature + // + if (wu_id_remainder < wu_id_modulus) { + sprintf(mod_clause, + " and wu.id %% %d = %d ", + wu_id_modulus, wu_id_remainder + ); + } else { + sprintf(mod_clause, " and wu.id = %u ", wu_id_remainder); + strcpy(main_clause, ""); + } } else { strcpy(mod_clause, ""); } @@ -1812,10 +1824,10 @@ int DB_VALIDATOR_ITEM_SET::enumerate( " res.runtime_outlier " "FROM " " workunit AS wu, result AS res where wu.id = res.workunitid " - " and wu.appid = %d and wu.need_validate > 0 %s " + " %s %s " "LIMIT " " %d ", - appid, mod_clause, nresult_limit + main_clause, mod_clause, nresult_limit ); retval = db->do_query(query); diff --git a/sched/validator.cpp b/sched/validator.cpp index 04c5374429..a89a24897b 100644 --- a/sched/validator.cpp +++ b/sched/validator.cpp @@ -44,6 +44,7 @@ // [--credit_from_runtime X] grant credit based on runtime, // assuming single-CPU app. // X is the max runtime. +// [--wu_id n] Validate WU n (debugging) #include "config.h" #include @@ -104,6 +105,7 @@ bool credit_from_runtime = false; double max_runtime = 0; bool no_credit = false; bool dry_run = false; +int wu_id = 0; int g_argc; char **g_argv; @@ -700,6 +702,11 @@ bool do_validate_scan() { // loop over entries that need to be checked // while (1) { + if (wu_id) { + // kludge to tell enumerate to return a given WU + wu_id_modulus = 1; + wu_id_remainder = wu_id; + } retval = validator.enumerate( app.id, SELECT_LIMIT, wu_id_modulus, wu_id_remainder, wu_id_min, wu_id_max, items @@ -716,6 +723,7 @@ bool do_validate_scan() { retval = handle_wu(validator, items); if (!retval) found = true; if (++i == one_pass_N_WU) break; + if (wu_id) break; } return found; } @@ -780,6 +788,7 @@ int main(int argc, char** argv) { " --credit_from_runtime X Grant credit based on runtime (max X seconds)and estimated FLOPS\n" " --no_credit Don't grant credit\n" " --sleep_interval n Set sleep-interval to n\n" + " --wu_id n Process WU with given ID\n" " -d n, --debug_level n Set log verbosity level, 1-4\n" " -h | --help Show this\n" " -v | --version Show version information\n"; @@ -830,6 +839,9 @@ int main(int argc, char** argv) { max_runtime = atof(argv[++i]); } else if (is_arg(argv[i], "no_credit")) { no_credit = true; + } else if (is_arg(argv[i], "wu_id")) { + wu_id = atoi(argv[++i]); + one_pass = true; } else { //log_messages.printf(MSG_CRITICAL, "unrecognized arg: %s\n", argv[i]); }