Closed Bug 1567961 Opened 6 years ago Closed 6 years ago

CloudFront invalidation might get repeated CallerReference

Categories

(developer.mozilla.org Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: peterbe, Assigned: peterbe)

Details

Attachments

(2 files)

See https://sentry.prod.mozaws.net/operations/mdn-prod/issues/6074311/?environment=oregon%3Aprod

InvalidArgument: An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains a caller reference that was used for a previous invalidation batch for the same distribution.
  File "celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "newrelic/hooks/application_celery.py", line 85, in wrapper
    return wrapped(*args, **kwargs)
  File "celery/app/trace.py", line 648, in __protected_call__
    return self.run(*args, **kwargs)
  File "kuma/api/tasks.py", line 188, in request_cdn_cache_invalidation
    'CallerReference': str(time.time())
  File "botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)

When you're doing a CloudFront invalidation request, you have to set a string called CallerReference. At the moment we're using a timestamp formatted as a string with 2 significant figures. E.g '1563813532.18'
The problem with this is that it might be repeated between invalidations. For example, if two concurrent worker tasks at getting two "simultaneous" requests to send an invalidation, within 10ms, they'll get the same CallerReference.

Probably the easiest thing to do is to just massively increase the entropy of that string but using more significant figures. E.g. '1563813821.164395'. Another thing we could do is to make the string depend on the paths list that is available in that loop.

Assignee: nobody → peterbe
Commit merged into master by Ryan Johnson (escattone) Authored by Peter Bengtsson (peterbe)
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: