question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retry partial failures

See original GitHub issue

Hi,

Some AWS APIs can complete with partial success. For example, when calling a PutRecords request with 500 entries, it is possible for some of the records to successfully get put and some fail.

PutRecordsRequest request = new PutRecordsRequest();
// add 500 entries to the request
PutRecordsResult response = producer.putRecords(request);
// response.getFailedRecordCount() could be between 0 and 500
// For example, the first 300 records might get inserts and the last 200 fail due to exceeding throughput 

In such cases:

  1. the client should wait a bit,
  2. retrieve the index of failed records from response and fetch those failed records to build a new request
  3. re-call producer.putRecords with the new request

So every invocation needs access to the result of the previous execution (or null for the first execution).

Is this possible to do with failsafe? From what I can see invocations do not have access to results of previous attempts.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
BenRombergcommented, Jul 18, 2018

First of all, great library - we use it for over a year now and are quite happy with it.

We have the exact same use-case (PutRecords for AWS Kinesis) and have worked around Failsafe’s limitations like this:

AtomicReference<List<PutRecordsRequestEntry>> currentRequestEntries = new AtomicReference<>(putRecordsRequestEntries);
List<PutRecordsRequestEntry> unsuccessfulRequestEntries = Failsafe.with(
        new RetryPolicy().<List<PutRecordsRequestEntry>>retryIf(
                recordsToRetry -> !recordsToRetry.isEmpty()))
        .get(() -> {
            List<PutRecordsRequestEntry> newRequestEntries = putRecords(currentRequestEntries.get());
            currentRequestEntries.set(newRequestEntries);
            return newRequestEntries;
        });

Would be great if Failsafe could support this so we can remove the AtomicReference workaround.

1reaction
jhaltermancommented, Aug 12, 2019

With the addition of ExecutionContext.getLastResult and getLastFailure I’m going to consider this closed. Feel free to comment and/or reopen if you feel those are inadequate for your use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle SQS message failure in batch with partial ... - Medium
In this case, let's say the first 2 messages in the batch are processed successfully and deleted. The 3rd message failed and lambda...
Read more >
Retry partial failures · Issue #105 - GitHub
Hi,. Some AWS APIs can complete with partial success. For example, when calling a PutRecords request with 500 entries, it is possible for...
Read more >
AWS Lambda now supports partial batch response for SQS as ...
The Partial Batch Response feature an SQS queue will only retain those records which could not be successfully processed, improving processing ...
Read more >
Complete Failures and Partial Failures of a Resource
A partial failure causes the fault monitor to increase by a fractional amount the count of complete failures in the retry interval.
Read more >
Three Ways to Retry Failures In Your Serverless Application
When retrying a failure, it's standard practice to exponentially backoff with each retry using jitter. Jitter is a random delay used to prevent ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found