Browse files

Merge pull request #43 from bshi/wale-38

Eliminate unecessary logging on restore
  • Loading branch information...
2 parents c5f05e6 + 879124a commit 473b2b31ef6a903e90e0a7d901f3bb1abb43f777 @bshi bshi committed Oct 18, 2013
Showing with 20 additions and 11 deletions.
  1. +20 −11 wal_e/worker/s3_worker.py
View
31 wal_e/worker/s3_worker.py
@@ -312,8 +312,20 @@ def standard_detail_message(prefix=''):
@retry(retry_with_count(log_wal_fetch_failures_on_error))
def download():
+ missing_uri_hint = ('This can be normal when Postgres is trying to '
+ 'detect what timelines are available during '
+ 'restoration.')
with open(path, 'wb') as decomp_out:
key = uri_to_key(aws_access_key_id, aws_secret_access_key, s3_url)
+ if not key.exists():
+ # Do not retry if the key not present, this can happen
+ # under normal situations.
+ logger.info(
+ msg='could not locate object while performing wal restore',
+ detail=('The absolute URI that could not be located '
+ 'is {url}.'.format(url=s3_url)),
+ hint=missing_uri_hint)
+ return False
pipeline = get_download_pipeline(PIPE, decomp_out, decrypt)
g = gevent.spawn(write_and_close_thread, key, pipeline.stdin)
@@ -323,17 +335,14 @@ def download():
g.get()
except boto.exception.S3ResponseError, e:
if e.status == 404:
- # Do not retry if the key not present, this can happen
- # under normal situations.
- logger.info(
- msg=('could not locate object while performing wal '
- 'restore'),
- detail=('The absolute URI that could not be located '
- 'is {url}.'.format(url=s3_url)),
- hint=('This can be normal when Postgres is trying to '
- 'detect what timelines are available during '
- 'restoration.'))
-
+ # Short circuit any re-try attempts under certain race
+ # conditions.
+ logger.warn(
+ msg=('could no longer locate object while performing '
+ 'wal restore'),
+ detail=('The URI at {url} no longer '
+ 'exists.'.format(url=s3_url)),
+ hint=missing_uri_hint)
return False
else:
raise

0 comments on commit 473b2b3

Please sign in to comment.