Very large update requests trigger failure to sync due to revsDiff failure

Abierto
#9,111 7 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
43/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript
Área
databases

Línea de trabajo

Comienza por la implementación de api.revsDiff mostrada en la issue y examina cómo JSON.stringify gestiona grandes payloads de diferencias de revisiones que contienen adjuntos. Reproduce el fallo con un batch grande y determina después cómo debería la ruta de la request gestionar el RangeError o reducir el batch. Se considera terminado cuando las update requests grandes ya no dejan de sincronizarse de forma silenciosa o repetida.

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

Descripción

I've just diagnosed a problem we were having where sometimes our local pouchDB database did not sync to the remote CouchDB. The source of the problem turned out to be due to our use of a very large batch size (1000) combined with a number of large attachments on documents.

The problem occurs in the implementation of revsDiff:

 api.revsDiff = adapterFun('revsDiff', async function (req, opts, callback) {
    // If no options were given, set the callback to be the second parameter
    if (typeof opts === 'function') {
      callback = opts;
      opts = {};
    }
 
    try {
      // Get the missing document/revision IDs
      const result = await fetchJSON(genDBUrl(host, '_revs_diff'), {
        method: 'POST',
        body: JSON.stringify(req)
      });
      callback(null, result.data);
    } catch (error) {
      callback(error);
    }
  });

We were seeing the failure of JSON.stringify with our large payload (RangeError: Invalid string length). This meant that the POST request was not sent. PouchDB then went on to try again with the same payload and failed again.

There is most likely an error reported via the appropriate handler but we missed it.

The solution was to reduce the batch size so that the payload of one request was much smaller.

However, I feel that this is something that could be worked around inside PouchDB - perhaps backing off to smaller batches in the case of a RangeError in this function.

Posting here for reference in case others see this issue and in case this can be prioritised for a fix.

Lenguaje dominante
JavaScript
Estrellas
17.6k
Forks
1.5k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/pouchdb

Todos los issues de apache/pouchdb

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.