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

オープン
#9,111 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
43/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
databases

調査の方向性

issue に示されている api.revsDiff の実装から始め、JSON.stringify が添付ファイルを含む大きなリビジョン差分 payload をどのように処理するかを調べます。大きな batch で失敗を再現し、その後、request path で RangeError を処理するか batch を小さくするにはどうすべきかを判断します。大きな update requests が、同期にサイレントに、または繰り返し失敗しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
17.6k
フォーク
1.5k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/pouchdb のほかの issue

apache/pouchdb の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。