Skip to content

Commit 1423143

Browse files
db_purge: remove --retired_wus option
Never purge WUs/results of a non-retired batch.
1 parent 11c12a0 commit 1423143

6 files changed

Lines changed: 40 additions & 53 deletions

File tree

html/inc/submit_util.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,19 +393,19 @@ function abort_batch($batch) {
393393
}
394394

395395
// retire a batch:
396-
// - mark the batch as retired (don't delete it; might be useful later)
396+
// - mark the batch as retired (don't delete it)
397397
// - delete output files (results/batchid/)
398398
// - mark unsent WUs as cancelled
399399
//
400400
// Don't delete the batch; it may have in-progress jobs that
401-
// we still need to file-delete and purge,
401+
// we'll need to file-delete and purge,
402402
// and the batch needs to be present for this.
403403
// Use ops/delete_batches.php to delete retired batches with no WUs
404404
//
405405
function retire_batch($batch) {
406406
system("rm -rf ../../results/$batch->id");
407407

408-
// get list of unsent WUs in this batch
408+
// we need to call get_batch_params() to set WU.status
409409
//
410410
$wus = BoincWorkunit::enum_fields(
411411
'id, rsc_fpops_est, canonical_credit, canonical_resultid, error_mask',
@@ -414,6 +414,9 @@ function retire_batch($batch) {
414414
get_batch_params($batch, $wus);
415415
$batch->update("state=".BATCH_STATE_RETIRED);
416416
// do this AFTER get_batch_params()
417+
418+
// get list of unsent WUs in this batch
419+
//
417420
$wu_ids = [];
418421
foreach ($wus as $wu) {
419422
if ($wu->status == WU_UNSENT) {

html/user/submit.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ function handle_retire_batch($user) {
10381038
} else {
10391039
page_head("Confirm retire batch");
10401040
echo "
1041+
<p>
10411042
Retiring a batch will remove all of its output files.
10421043
Are you sure you want to do this?
10431044
<p>

sched/assimilator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
'''
33
Generic Assimilator framework
4+
5+
NOT SUPPORTED. Use script_assimilator instead
46
'''
57

68
import os, re, signal, sys, time, hashlib

sched/db_purge.cpp

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
// to XML archive files,
2424
// then deleting it and the results from the DB.
2525
//
26-
// if --retired_wus:
27-
// purge WUs for which file_delete_state=FILE_DELETE_DONE
28-
// and the WU is in a retired batch
29-
// otherwise
30-
// purge WUs for which file_delete_state=FILE_DELETE_DONE.
26+
// Purge WUs for which file_delete_state == FILE_DELETE_DONE
27+
// and the WU is either
28+
// - in a retired batch
29+
// - not in a batch
3130
//
3231
// The XML files have names of the form
3332
// wu_archive_TIME and result_archive_TIME
@@ -70,7 +69,6 @@ void usage() {
7069
"Purge workunit and result records that are no longer needed.\n\n"
7170
"Usage: db_purge [options]\n"
7271
" -d N or --debug_level N Set verbosity level (1-4; 3=normal, 4=debug)\n"
73-
" --retired_wus purge WUs only from retired batches\n"
7472
" --min_age_days N Purge Wus w/ mod time at least N days ago\n"
7573
" --max N Purge at most N WUs\n"
7674
" --zip Compress output files by piping through zip\n"
@@ -236,7 +234,6 @@ double min_age_days = 0;
236234
bool no_archive = false;
237235
bool dont_delete = false;
238236
bool daily_dir = false;
239-
bool retired_wus = false;
240237
int max_number_workunits_to_purge = 0;
241238
// If nonzero, maximum number of workunits to purge.
242239
// Since all results associated with a purged workunit are also purged,
@@ -255,8 +252,6 @@ int id_modulus=0, id_remainder=0;
255252
// allow more than one to run - doesn't work if archiving is enabled
256253
char app_name[256];
257254
DB_APP app;
258-
string retired_batch_ids;
259-
// if --retired_wus, a list of retired batch IDs as "id1,id2,..."
260255

261256
bool time_to_quit() {
262257
if (max_number_workunits_to_purge) {
@@ -611,38 +606,37 @@ int purge_and_archive_results(DB_WORKUNIT& wu, int& number_results) {
611606
return 0;
612607
}
613608

614-
// get list of IDs of retired batches
609+
// get list of IDs of retired batches (and 0, = no batch)
615610
//
616611
int get_retired_batch_ids(string &out) {
617-
out.clear();
612+
out = "0";
618613
char query[256];
619614
sprintf(query, "select id from batch where state=%d", BATCH_STATE_RETIRED);
620615
int retval = boinc_db.do_query(query);
621-
if (retval) return mysql_errno(boinc_db.mysql);
616+
if (retval) {
617+
return mysql_errno(boinc_db.mysql);
618+
}
622619

623620
MYSQL_RES *rp;
624621
rp = mysql_store_result(boinc_db.mysql);
625-
if (!rp) return mysql_errno(boinc_db.mysql);
626-
bool first = true;
622+
if (!rp) {
623+
return mysql_errno(boinc_db.mysql);
624+
}
627625
while (1) {
628626
MYSQL_ROW row = mysql_fetch_row(rp);
629627
if (!row) {
630628
mysql_free_result(rp);
631629
break;
632630
}
633-
if (first) {
634-
first = false;
635-
} else {
636-
out += ",";
637-
}
631+
out += ",";
638632
out += row[0];
639633
}
640634
return 0;
641635
}
642636

643637
// return true if did anything
644638
//
645-
bool do_pass() {
639+
bool do_pass(string &retired_batch_ids) {
646640
int retval = 0;
647641

648642
// The number of workunits/results purged in a single pass of do_pass().
@@ -683,13 +677,9 @@ bool do_pass() {
683677
sprintf(buf, " and appid=%lu", app.id);
684678
clause += buf;
685679
}
686-
if (retired_wus) {
687-
clause += " and batch in (";
688-
clause += retired_batch_ids;
689-
clause += ")";
690-
} else {
691-
clause += " and batch=0";
692-
}
680+
clause += " and batch in (";
681+
clause += retired_batch_ids;
682+
clause += ")";
693683

694684
sprintf(buf, " limit %d", DB_QUERY_LIMIT);
695685
clause += buf;
@@ -862,8 +852,6 @@ int main(int argc, char** argv) {
862852
max_wu_per_file = atoi(argv[i]);
863853
} else if (is_arg(argv[i], "no_archive")) {
864854
no_archive = true;
865-
} else if (is_arg(argv[i], "retired_wus")) {
866-
retired_wus = true;
867855
} else if (is_arg(argv[i], "sleep")) {
868856
if (!argv[++i]) {
869857
log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
@@ -957,25 +945,14 @@ int main(int argc, char** argv) {
957945
if (time_to_quit()) {
958946
break;
959947
}
960-
if (retired_wus) {
961-
retval = get_retired_batch_ids(retired_batch_ids);
962-
if (retval) {
963-
log_messages.printf(MSG_CRITICAL,
964-
"Can't get retired batch IDs"
965-
);
966-
exit(1);
967-
}
968-
if (retired_batch_ids.empty()) {
969-
log_messages.printf(MSG_NORMAL,
970-
"no retired batches; sleeping %d\n",
971-
sleep_sec
972-
);
973-
daemon_sleep(sleep_sec);
974-
continue;
975-
}
948+
string retired_batch_ids;
949+
retval = get_retired_batch_ids(retired_batch_ids);
950+
if (retval) {
951+
log_messages.printf(MSG_CRITICAL, "Can't get retired batch IDs");
952+
exit(1);
976953
}
977954

978-
bool did_something = do_pass();
955+
bool did_something = do_pass(retired_batch_ids);
979956
if (one_pass) {
980957
break;
981958
}

sched/file_deleter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
// You should have received a copy of the GNU Lesser General Public License
1616
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
1717

18-
19-
// file deleter. See usage() below for usage.
20-
// skips WUs with 'nodelete' in the name
21-
// skips files with <no_delete/> in the <file_info>
18+
// file deleter.
19+
// enumerate WUs and results with file_delete_state == FILE_DELETE_READY,
20+
// and delete the associated files.
21+
// skip WUs with 'nodelete' in the name
22+
// skip files with <no_delete/> in the <file_info>
2223

2324
// enum sizes. RESULT_PER_ENUM is three times larger on the
2425
// assumption of 3-fold average redundancy.

tools/process_input_template.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
// by scanning the input template, macro-substituting the input files,
2121
// and putting in the command line element and additional XML
2222
//
23+
// Input files must already be staged.
24+
// If the .md5 file is not present, create it.
25+
//
2326
// Called (only) in create_work.cpp
2427

2528
#include <stdio.h>

0 commit comments

Comments
 (0)