Skip to content

Commit

Permalink
Python API: tolerate errors during EC chunk upload finish
Browse files Browse the repository at this point in the history
  • Loading branch information
fvennetier committed Jun 20, 2019
1 parent 5e60b7a commit f115447
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions oio/api/ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def finish(self, metachunk_size, metachunk_hash):
if self.failed:
logger.debug("NOT sending end marker and trailers to %s, "
"because upload has failed", self.chunk['url'])
return
return False
logger.debug("Sending end marker and trailers to %s",
self.chunk['url'])
parts = [
Expand All @@ -676,10 +676,19 @@ def finish(self, metachunk_size, metachunk_hash):
self.checksum.hexdigest()))
parts.append('\r\n')
to_send = "".join(parts)
self.conn.send(to_send)
# Last segment sent, disable TCP_CORK to flush buffers
self.conn.set_cork(False)
eventlet_yield()
try:
with ChunkWriteTimeout(self.write_timeout):
self.conn.send(to_send)
# Last segment sent, disable TCP_CORK to flush buffers
self.conn.set_cork(False)
eventlet_yield()
except (Exception, ChunkWriteTimeout) as exc:
self.failed = True
msg = str(exc)
logger.warn("Failed to finish %s (%s, reqid=%s)",
self.chunk, msg, self.reqid)
self.chunk['error'] = 'finish: %s' % msg
return False
return True

def getresponse(self):
Expand Down Expand Up @@ -945,6 +954,10 @@ def _get_response(self, writer):
logger.warn("Failed to read response for %s (reqid=%s): %s",
writer.chunk, self.reqid, msg)
writer.chunk['error'] = 'resp: %s' % msg
# close_source() will be called in a finally block later.
# But we do not want to wait for all writers to have finished writing
# before closing connections.
io.close_source(writer)
return (writer, resp)


Expand Down

0 comments on commit f115447

Please # to comment.