some tweaks to speed rollback logic

This commit is contained in:
Ryan Tucker 2010-01-18 17:06:05 -05:00
parent 55e1a5cb4a
commit f87dbdafc9

View file

@ -119,8 +119,9 @@ class SlowFile:
time.sleep(sleepfor) time.sleep(sleepfor)
else: else:
# we're late; something got slow. # we're late; something got slow.
self.delayfactor += 0.5 lateness = starttime - self.lastblocktargettime
logger.debug('%.2f seconds late (congestion?); setting delayfactor to %.2f' % (starttime - self.lastblocktargettime, self.delayfactor)) self.delayfactor += lateness
logger.debug('%.2f seconds late (congestion?); setting delayfactor to %.2f' % (lateness, self.delayfactor))
targetspeed = self.speed/float(self.delayfactor) targetspeed = self.speed/float(self.delayfactor)
self.lastblocktargettime = time.time() + len/float(targetspeed) self.lastblocktargettime = time.time() + len/float(targetspeed)
@ -128,7 +129,7 @@ class SlowFile:
if time.time() > self.lastdebug+300: if time.time() > self.lastdebug+300:
if self.delayfactor > 1: if self.delayfactor > 1:
# reduce the penalty a bit # reduce the penalty a bit
self.delayfactor = self.delayfactor / 2.0 self.delayfactor -= 0.1
if self.delayfactor < 1: if self.delayfactor < 1:
self.delayfactor = 1 self.delayfactor = 1
@ -317,7 +318,7 @@ for i in sorted(glob.glob(fileglob)):
key.set_acl('private') key.set_acl('private')
key.close() key.close()
retry_count = max_retries+1 retry_count = max_retries+1
except boto.exception.S3ResponseError, socket.error as e: except (boto.exception.S3ResponseError, socket.error) as e:
retry_count += 1 retry_count += 1
sleeptime = 2**retry_count sleeptime = 2**retry_count
err = 'Encountered exception %s, retrying in %i seconds (%i/%i)' % (e, sleeptime, retry_count, max_retries) err = 'Encountered exception %s, retrying in %i seconds (%i/%i)' % (e, sleeptime, retry_count, max_retries)