Commit 3d6c5566 authored by Guido Trotter's avatar Guido Trotter
Browse files

jqueue._LoadJobFromDisk: remove safety archival



Currently _LoadJobFromDisk archives job files it finds corrupted. Since
we want to use it to load files without holding locks, this could cause
a conflict: we just move the feature to _LoadJobUnlocked which is always
called with the lock held.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 85a87e21
......@@ -184,6 +184,12 @@ class JobLost(GenericError):
"""
class JobFileCorrupted(GenericError):
"""Job file could not be properly decoded/restored.
"""
class ResolverError(GenericError):
"""Host name cannot be resolved.
......
......@@ -985,7 +985,19 @@ class JobQueue(object):
logging.debug("Found job %s in memcache", job_id)
return job
job = self._LoadJobFromDisk(job_id)
try:
job = self._LoadJobFromDisk(job_id)
except errors.JobFileCorrupted:
old_path = self._GetJobPath(job_id)
new_path = self._GetArchivedJobPath(job_id)
if old_path == new_path:
# job already archived (future case)
logging.exception("Can't parse job %s", job_id)
else:
# non-archived case
logging.exception("Can't parse job %s, will archive.", job_id)
self._RenameFilesUnlocked([(old_path, new_path)])
return None
self._memcache[job_id] = job
logging.debug("Added job %s to the cache", job_id)
......@@ -1015,15 +1027,7 @@ class JobQueue(object):
data = serializer.LoadJson(raw_data)
job = _QueuedJob.Restore(self, data)
except Exception, err: # pylint: disable-msg=W0703
new_path = self._GetArchivedJobPath(job_id)
if filepath == new_path:
# job already archived (future case)
logging.exception("Can't parse job %s", job_id)
else:
# non-archived case
logging.exception("Can't parse job %s, will archive.", job_id)
self._RenameFilesUnlocked([(filepath, new_path)])
return None
raise errors.JobFileCorrupted(err)
return job
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment