|
11 | 11 | from DIRAC import S_ERROR, S_OK |
12 | 12 | from DIRAC.Core.Base.DB import DB |
13 | 13 | from DIRAC.Core.Utilities import TimeUtilities |
| 14 | +from DIRAC.Core.Utilities.ReturnValues import returnValueOrRaise, convertToReturnValue |
14 | 15 | from DIRAC.FrameworkSystem.Client.Logger import contextLogger |
15 | 16 |
|
16 | 17 | MAGIC_EPOC_NUMBER = 1270000000 |
@@ -145,21 +146,33 @@ def getJobLoggingInfo(self, jobID): |
145 | 146 | return S_OK(return_value) |
146 | 147 |
|
147 | 148 | ############################################################################# |
| 149 | + @convertToReturnValue |
148 | 150 | def deleteJob(self, jobID): |
149 | 151 | """Delete logging records for given jobs""" |
150 | 152 | if not jobID: |
151 | | - return S_OK() |
| 153 | + return None |
152 | 154 |
|
153 | | - # Make sure that we have a list of strings of jobIDs |
154 | 155 | if isinstance(jobID, int): |
155 | | - jobList = [str(jobID)] |
| 156 | + jobList = [jobID] |
156 | 157 | elif isinstance(jobID, str): |
157 | 158 | jobList = jobID.replace(" ", "").split(",") |
158 | 159 | else: |
159 | | - jobList = list(str(j) for j in jobID) |
| 160 | + jobList = jobID |
160 | 161 |
|
161 | | - req = f"DELETE FROM LoggingInfo WHERE JobID IN ({','.join(jobList)})" |
162 | | - return self._update(req) |
| 162 | + sqlCmd = ( |
| 163 | + "CREATE TEMPORARY TABLE to_delete_LoggingInfo (JobID INTEGER NOT NULL, PRIMARY KEY (JobID)) ENGINE=MEMORY;" |
| 164 | + ) |
| 165 | + returnValueOrRaise(self._update(sqlCmd)) |
| 166 | + try: |
| 167 | + sqlCmd = "INSERT INTO to_delete_LoggingInfo (EntityId) VALUES ( %s )" |
| 168 | + returnValueOrRaise(self._updatemany(sqlCmd, [(j,) for j in jobList])) |
| 169 | + sqlCmd = "DELETE l from `LoggingInfo` l JOIN to_delete_LoggingInfo t USING (JobID)" |
| 170 | + result = returnValueOrRaise(self._update(sqlCmd)) |
| 171 | + finally: |
| 172 | + sqlCmd = "DROP TEMPORARY TABLE to_delete_LoggingInfo" |
| 173 | + returnValueOrRaise(self._update(sqlCmd)) |
| 174 | + |
| 175 | + return result |
163 | 176 |
|
164 | 177 | ############################################################################# |
165 | 178 | def getWMSTimeStamps(self, jobID): |
|
0 commit comments