Skip to content

Commit 17e86b6

Browse files
authored
Merge pull request #7301 from DIRACGridBot/cherry-pick-2-320ecd4b2-integration
[sweep:integration] Fix race condition in the JobLoggingDB
2 parents 07467b1 + 8644661 commit 17e86b6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ def addLoggingRecord(
6262
except Exception:
6363
self.log.exception("Exception while date evaluation")
6464
_date = datetime.datetime.utcnow()
65-
epoc = time.mktime(_date.timetuple()) + _date.microsecond / 1000000.0 - MAGIC_EPOC_NUMBER
65+
66+
# We need to specify that timezone is UTC because otherwise timestamp
67+
# assumes local time while we mean UTC.
68+
epoc = _date.replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER
6669

6770
cmd = (
6871
"INSERT INTO LoggingInfo (JobId, Status, MinorStatus, ApplicationStatus, "
@@ -129,7 +132,7 @@ def getWMSTimeStamps(self, jobID):
129132
# self.log.debug('getWMSTimeStamps: Retrieving Timestamps for Job %d' % int(jobID))
130133

131134
result = {}
132-
cmd = "SELECT Status,StatusTimeOrder FROM LoggingInfo WHERE JobID=%d" % int(jobID)
135+
cmd = "SELECT Status,StatusTimeOrder FROM LoggingInfo WHERE JobID=%d ORDER BY StatusTimeOrder" % int(jobID)
133136
resCmd = self._query(cmd)
134137
if not resCmd["OK"]:
135138
return resCmd

0 commit comments

Comments
 (0)