Skip to content

Commit dbc4ace

Browse files
authored
Merge pull request #6947 from BOINC/dpa_db_purge2
db_purge: ignore wu.batch unless --batch option
2 parents 684c84e + 2c971ac commit dbc4ace

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

sched/db_purge.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
// then deleting it and the results from the DB.
2525
//
2626
// Purge WUs for which file_delete_state == FILE_DELETE_DONE
27-
// and the WU is either
27+
// and if --batch:
28+
// the WU is either
2829
// - in a retired batch
2930
// - not in a batch
3031
//
@@ -69,6 +70,7 @@ void usage() {
6970
"Purge workunit and result records that are no longer needed.\n\n"
7071
"Usage: db_purge [options]\n"
7172
" -d N or --debug_level N Set verbosity level (1-4; 3=normal, 4=debug)\n"
73+
" --batch purge batch jobs only if retired\n"
7274
" --min_age_days N Purge Wus w/ mod time at least N days ago\n"
7375
" --max N Purge at most N WUs\n"
7476
" --zip Compress output files by piping through zip\n"
@@ -232,6 +234,7 @@ void* re_index_stream=NULL;
232234
int time_int=0;
233235
double min_age_days = 0;
234236
bool no_archive = false;
237+
bool batch = false;
235238
bool dont_delete = false;
236239
bool daily_dir = false;
237240
int max_number_workunits_to_purge = 0;
@@ -677,9 +680,11 @@ bool do_pass(string &retired_batch_ids) {
677680
sprintf(buf, " and appid=%lu", app.id);
678681
clause += buf;
679682
}
680-
clause += " and batch in (";
681-
clause += retired_batch_ids;
682-
clause += ")";
683+
if (batch) {
684+
clause += " and batch in (";
685+
clause += retired_batch_ids;
686+
clause += ")";
687+
}
683688

684689
sprintf(buf, " limit %d", DB_QUERY_LIMIT);
685690
clause += buf;
@@ -808,6 +813,8 @@ int main(int argc, char** argv) {
808813
for (i=1; i<argc; i++) {
809814
if (is_arg(argv[i], "one_pass")) {
810815
one_pass = true;
816+
} else if (is_arg(argv[i], "batch")) {
817+
batch = true;
811818
} else if (is_arg(argv[i], "dont_delete")) {
812819
dont_delete = true;
813820
} else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) {
@@ -946,10 +953,15 @@ int main(int argc, char** argv) {
946953
break;
947954
}
948955
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);
956+
if (batch) {
957+
retval = get_retired_batch_ids(retired_batch_ids);
958+
if (retval) {
959+
log_messages.printf(MSG_CRITICAL,
960+
"Can't get retired batch IDs; retval %d\n",
961+
retval
962+
);
963+
exit(1);
964+
}
953965
}
954966

955967
bool did_something = do_pass(retired_batch_ids);

0 commit comments

Comments
 (0)