Permalink
Browse files

Eliminate unecessary logging on restore

Tweak race error message by bumping severity to WARNING and note in the
message copy that the URI at one point existed but can no longer be
found.
  • Loading branch information...
bshi committed Oct 11, 2013
1 parent c5f05e6 commit 879124a590765ad9086114e5957d43abd6081570
Showing with 20 additions and 11 deletions.
  1. +20 −11 wal_e/worker/s3_worker.py
View
@@ -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 879124a

Please sign in to comment.