algolia / algolia/algoliasearch-client-java

Adding a configuration for max retries to handle system wide outages

Offen
#789 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
52
Forks
33
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- Algolia Client Version: 3.16.6
- Language Version: Java

### Description
Correct me if I am mistaken but [HttpTransport.executeWithRetry](https://github.com/algolia/algoliasearch-client-java/blob/master/algoliasearch-core/src/main/java/com/algolia/search/HttpTransport.java#L150-L192) will before sending a request, increase the timeout for the request based on the number of retries. After the response is received, it uses *RetryStrategy* to determine what to do with the results.

The function [RetryStrategy.decide](https://github.com/algolia/algoliasearch-client-java/blob/master/algoliasearch-core/src/main/java/com/algolia/search/RetryStrategy.java#L52-L72C4) will in the case of a request time out, will *always* retry.

During an Indexer service outage in July 13th, it appears that was happening for the entire length of the outage causing the Promises to hang and never fail. This becomes a pretty big issue when using `BatchIndexingResponse.waitTask()` like in the API examples.

### Proposed change
1. Adding a new configurable property to ConfigBase called something along the lines of `maxRetriesPerHost` and update `RetryStrategy` to save that value in its constructor.
2. Update `RetryStrategy.decide` to something along the lines of
```
} else if (response.isTimedOut()) {
boolean shouldKeepUp = maxRetriesPerHost == null || tryableHost.getRetryCount() <= maxRetriesPerHost;
tryableHost.setUp(shouldKeepUp);
tryableHost.setLastUse(AlgoliaUtils.nowUTC());
tryableHost.incrementRetryCount();
return RetryOutcome.RETRY;
}
```

### Why make the change
During the time of the indexing outage, it was not clear immediately why our requests were stuck. Looking at the code it seems like if the servers actually responded with server errors, the `StatefulHost`s would have been turned off one by one which would be closer to what I would expect from an outage. The current logic has no way of determining this type of issue, causing ever expanding timeouts without any way of intervening.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit algoliasearch-core/src/main/java/com/algolia/search/HttpTransport.java, insbesondere mit executeWithRetry, und lies dann RetryStrategy.java und ConfigBase, um die Behandlung von Timeout und Wiederholungsanzahl nachzuverfolgen. Bestätige das Verhalten bei Requests mit abgelaufenem Timeout und definiere die Aufgabe als abgeschlossen, wenn ein konfigurierbares Wiederholungslimit pro Host vorhanden ist, das eine unbegrenzte Ausweitung der Wiederholungen verhindert und bei Nichtsetzung das bestehende Wiederholungsverhalten beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
api
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.