Describe the bug
html/ops/delete_job_files reaps job_file rows (and their download-hierarchy files) once delete_time has passed. Per its own header comment — and job_file.php's — it should delete a file only when it has no associations to active batches. The in-use check is inverted:
// associations to batches in state INIT / IN_PROGRESS (still active)
$query = "select * from DB.batch_file_assoc as bfa join DB.batch
where bfa.job_file_id=$file->id and bfa.batch_id=batch.id
and batch.state < BATCH_STATE_COMPLETE";
...
$b = _mysql_fetch_object($result);
if (!$b) continue; // no active-batch association -> skips deletion
... // active-batch association found -> deletes the file
if (!$b) continue; skips deletion when the file is not used by any active batch, and falls through to unlink() + $file->delete() when it is.
Impact
- A
job_file past its delete_time that's still referenced by an INIT/IN_PROGRESS batch has its input file deleted from download/ while jobs still need it -> download failures / WU errors.
- A
job_file whose batches are all COMPLETE/ABORTED/RETIRED is never reaped -> the file (these are the large shared input files remote submission is meant to support) leaks indefinitely.
The inverted condition has been present since the original 2013 Condor commit (7f4263b07); the 2017 "fix delete_job_files" (#1844) only corrected an unrelated md5->name reference. Blast radius is limited to projects that installed db/schema_condor.sql (so batch_file_assoc exists) and schedule this script themselves — it's in no stock config.xml task list.
Suggested fix
if (!$b) continue; -> if ($b) continue; (an active-batch association should prevent deletion).
While here: unlink($path) leaves the $path.md5 sidecar orphaned, and neither unlink return is checked.
Found while reviewing #6577 (which would build on this daemon).
Reported with AI assistance (Claude Sonnet 5); verified against master @ b4b1bad96f.
Describe the bug
html/ops/delete_job_filesreapsjob_filerows (and their download-hierarchy files) oncedelete_timehas passed. Per its own header comment — andjob_file.php's — it should delete a file only when it has no associations to active batches. The in-use check is inverted:if (!$b) continue;skips deletion when the file is not used by any active batch, and falls through tounlink()+$file->delete()when it is.Impact
job_filepast itsdelete_timethat's still referenced by an INIT/IN_PROGRESS batch has its input file deleted fromdownload/while jobs still need it -> download failures / WU errors.job_filewhose batches are all COMPLETE/ABORTED/RETIRED is never reaped -> the file (these are the large shared input files remote submission is meant to support) leaks indefinitely.The inverted condition has been present since the original 2013 Condor commit (
7f4263b07); the 2017 "fix delete_job_files" (#1844) only corrected an unrelatedmd5->namereference. Blast radius is limited to projects that installeddb/schema_condor.sql(sobatch_file_assocexists) and schedule this script themselves — it's in no stockconfig.xmltask list.Suggested fix
if (!$b) continue;->if ($b) continue;(an active-batch association should prevent deletion).While here:
unlink($path)leaves the$path.md5sidecar orphaned, and neitherunlinkreturn is checked.Found while reviewing #6577 (which would build on this daemon).
Reported with AI assistance (Claude Sonnet 5); verified against
master@b4b1bad96f.