Skip to content

Commit

Permalink
recovery: various fixes & cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
abudnik committed Jan 11, 2016
1 parent d77ef8c commit 8333f37
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions recovery/elliptics_recovery/types/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ def _server_send(self, keys, addr, backend_id, responses):

timeouted_keys = []
index = -1
for index, result in enumerate(iterator):
for index, result in enumerate(iterator, 1):
status = result.response.status
self._update_stats(start_time, index + 1, recovers_in_progress, status)
self._update_stats(start_time, index, recovers_in_progress, status)
key = result.response.key
log.debug("Server-send result: key: {0}, status: {1}".format(key, status))
if status == -errno.ETIMEDOUT:
Expand All @@ -334,22 +334,23 @@ def _remove_bad_keys(self, responses):
bad_keys.append((key, ) + response)

for attempt in range(self.ctx.attempts):
if bad_keys:
results = []
for k in bad_keys:
key, _, addr, backend_id = k
self.remove_session.set_direct_id(addr, backend_id)
result = self.remove_session.remove(elliptics.Id(key))
results.append(result)

timeouted_keys = []
is_last_attempt = (attempt == self.ctx.attempts - 1)
for i, r in enumerate(results):
status = r.get()[0].status
log.info("Removing key: {0}, status: {1}, last attempt: {2}".format(bad_keys[i], status, is_last_attempt))
if status == -errno.ETIMEDOUT:
timeouted_keys.append(bad_keys[i])
bad_keys = timeouted_keys
if not bad_keys:
break

results = []
for key, _, addr, backend_id in bad_keys:
self.remove_session.set_direct_id(addr, backend_id)
result = self.remove_session.remove(elliptics.Id(key))
results.append(result)

timeouted_keys = []
is_last_attempt = (attempt == self.ctx.attempts - 1)
for i, r in enumerate(results):
status = r.get()[0].status
log.info("Removing key: {0}, status: {1}, last attempt: {2}".format(bad_keys[i], status, is_last_attempt))
if status == -errno.ETIMEDOUT:
timeouted_keys.append(bad_keys[i])
bad_keys = timeouted_keys

def _check_bad_key(self, response):
status = response[0]
Expand Down

0 comments on commit 8333f37

Please sign in to comment.