Skip to content

Commit

Permalink
Merge pull request DIRACGrid#7300 from chaen/utcTimeStamp
Browse files Browse the repository at this point in the history
Fix race condition in the JobLoggingDB
  • Loading branch information
fstagni committed Nov 22, 2023
2 parents e7d0d29 + 9ec7ccf commit 320ecd4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def addLoggingRecord(
except Exception:
self.log.exception("Exception while date evaluation")
_date = datetime.datetime.utcnow()
epoc = time.mktime(_date.timetuple()) + _date.microsecond / 1000000.0 - MAGIC_EPOC_NUMBER

# We need to specify that timezone is UTC because otherwise timestamp
# assumes local time while we mean UTC.
epoc = _date.replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER

cmd = (
"INSERT INTO LoggingInfo (JobId, Status, MinorStatus, ApplicationStatus, "
Expand Down Expand Up @@ -138,7 +141,7 @@ def getWMSTimeStamps(self, jobID):
# self.log.debug('getWMSTimeStamps: Retrieving Timestamps for Job %d' % int(jobID))

result = {}
cmd = "SELECT Status,StatusTimeOrder FROM LoggingInfo WHERE JobID=%d" % int(jobID)
cmd = "SELECT Status,StatusTimeOrder FROM LoggingInfo WHERE JobID=%d ORDER BY StatusTimeOrder" % int(jobID)
resCmd = self._query(cmd)
if not resCmd["OK"]:
return resCmd
Expand Down

0 comments on commit 320ecd4

Please sign in to comment.