algolia / algolia/algoliasearch-client-java

Adding a configuration for max retries to handle system wide outages

Abierto
#789 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
52
Forks
33
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

- 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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza con algoliasearch-core/src/main/java/com/algolia/search/HttpTransport.java, especialmente con executeWithRetry, y después lee RetryStrategy.java y ConfigBase para seguir el tratamiento del timeout y del número de reintentos. Confirma el comportamiento durante las solicitudes cuyo timeout ha expirado y define el trabajo como terminado cuando exista un límite de reintentos configurable por host que impida que los reintentos se expandan indefinidamente, preservando el comportamiento de reintentos existente cuando no esté configurado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
api
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.