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

Aperta
#9,111 7 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
43/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
databases

Direzione di ricerca

Parti dall’implementazione di api.revsDiff mostrata nell’issue ed esamina come JSON.stringify gestisce payload di grandi dimensioni con differenze di revisione contenenti allegati. Riproduci il fallimento con un batch di grandi dimensioni, quindi determina come il percorso della request dovrebbe gestire il RangeError o ridurre il batch. Il lavoro è completato quando le grandi update requests non smettono più di sincronizzarsi in modo silenzioso o ripetuto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
17.6k
Fork
1.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/pouchdb

Tutte le issue di apache/pouchdb

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.