Commit 36f5d30f authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

always clear hearbeat when sync fails

parent 9111f177
...@@ -41,14 +41,14 @@ class FileClient(object): ...@@ -41,14 +41,14 @@ class FileClient(object):
if callback is not None: if callback is not None:
callback(synced_source_state, synced_target_state) callback(synced_source_state, synced_target_state)
except common.SyncError as e: except common.SyncError as e:
hard = isinstance(e, common.HardSyncError)
if failure_callback is not None:
failure_callback(source_handle.source_state, hard=hard)
msg = messaging.SyncErrorMessage( msg = messaging.SyncErrorMessage(
objname=target_state.objname, objname=target_state.objname,
serial=source_handle.source_state.serial, serial=source_handle.source_state.serial,
exception=e, logger=logger) exception=e, logger=logger)
self.settings.messager.put(msg) self.settings.messager.put(msg)
if isinstance(e, common.HardSyncError):
if failure_callback is not None:
def _start(self, source_handle, target_state, sync_state): def _start(self, source_handle, target_state, sync_state):
try: try:
...@@ -288,14 +288,15 @@ class FileSyncer(object): ...@@ -288,14 +288,15 @@ class FileSyncer(object):
callback=self.ack_file_sync, callback=self.ack_file_sync,
failure_callback=self.mark_as_failed) failure_callback=self.mark_as_failed)
def mark_as_failed(self, state): def mark_as_failed(self, state, hard=False):
serial = state.serial serial = state.serial
objname = state.objname objname = state.objname
with self.heartbeat.lock() as hb:
if hard:
logger.warning( logger.warning(
"Marking failed serial %s for archive: %s, object: '%s'" % "Marking failed serial %s for archive: %s, object: '%s'" %
(serial, state.archive, objname)) (serial, state.archive, objname))
with self.heartbeat.lock() as hb:
with self.failed_serials.lock() as d: with self.failed_serials.lock() as d:
d[(serial, objname)] = state d[(serial, objname)] = state
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