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):
if callback is not None:
callback(synced_source_state, synced_target_state)
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(
objname=target_state.objname,
serial=source_handle.source_state.serial,
exception=e, logger=logger)
self.settings.messager.put(msg)
if isinstance(e, common.HardSyncError):
if failure_callback is not None:
failure_callback(source_handle.source_state)
def _start(self, source_handle, target_state, sync_state):
try:
......
......@@ -288,16 +288,17 @@ class FileSyncer(object):
callback=self.ack_file_sync,
failure_callback=self.mark_as_failed)
def mark_as_failed(self, state):
def mark_as_failed(self, state, hard=False):
serial = state.serial
objname = state.objname
logger.warning(
"Marking failed serial %s for archive: %s, object: '%s'" %
(serial, state.archive, objname))
with self.heartbeat.lock() as hb:
hb.pop(objname)
with self.failed_serials.lock() as d:
d[(serial, objname)] = state
if hard:
logger.warning(
"Marking failed serial %s for archive: %s, object: '%s'" %
(serial, state.archive, objname))
with self.failed_serials.lock() as d:
d[(serial, objname)] = state
def update_state(self, old_state, new_state):
db = self.get_db()
......
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