Skip to content

Commit ee79ce4

Browse files
authored
Merge pull request #7476 from atsareg/fix-delete-job
[8.0] Optimization of job deletion
2 parents f625cf2 + cab3fc6 commit ee79ce4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/JobCleaningAgent.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,18 @@ def _getJobsList(self, condDict, delay=None):
260260
261261
:param dict condDict: a dict like {'JobType': 'User', 'Status': 'Killed'}
262262
:param int delay: days of delay
263-
:returns: S_OK with jobsList
263+
:returns: S_OK with a list of job IDs
264264
"""
265-
jobIDsS = set()
265+
266266
delayStr = f"and older than {delay}" if delay else ""
267267
self.log.info(f"Get jobs with {str(condDict)} {delayStr}")
268-
for order in ["JobID:ASC", "JobID:DESC"]:
269-
result = self.jobDB.selectJobs(condDict, older=delay, orderAttribute=order, limit=self.maxJobsAtOnce)
270-
if not result["OK"]:
271-
return result
272-
jobIDsS = jobIDsS.union({int(jID) for jID in result["Value"]})
273268

274-
return S_OK(list(jobIDsS))
269+
# Select a random set of jobs
270+
result = self.jobDB.selectJobs(condDict, older=delay, orderAttribute="RAND()", limit=self.maxJobsAtOnce)
271+
if not result["OK"]:
272+
return result
273+
274+
return S_OK(result["Value"])
275275

276276
def _getOwnerJobsDict(self, jobList):
277277
"""

0 commit comments

Comments
 (0)