Document Deletion Not Replicated with Low revs_limit (CouchDB → PouchDB)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, react-native
- 領域
- databases, mobile-dev
調査の方向性
isDeleted 関数と提供された rev_tree メタデータから始め、低い revs_limit と削除前の複数の更新を使用して CouchDB-to-PouchDB シナリオを再現します。削除が切り詰められたリビジョン履歴に続く場合に、原因を確認し、削除されたドキュメントが PouchDB から削除されることを保証できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
🔄 Document Deletion Not Replicated with Low revs_limit (CouchDB → PouchDB)
Hi,
I'm encountering a document deletion issue when replicating data from CouchDB to PouchDB with a low revs_limit.
🧠 Context
I'm using a one-way replication mechanism from CouchDB → PouchDB in a React Native application. Documents are updated daily in CouchDB and replicated to PouchDB. No changes are made in PouchDB — it's read-only.
Because documents were accumulating hundreds of revisions (sometimes 400+), we decided to limit the revision history by setting revs_limit = 1 on the CouchDB database, since we do not need any revision history.
This approach generally works well — documents update fine even with multiple revision gaps.
❌ Problem: Deletions Are Not Propagated
However, we're running into a problem with deleted documents not being removed from PouchDB.
🧪 Reproduction Scenario (with revs_limit = 3)
- A document is created in CouchDB.
- It is replicated to PouchDB.
- The document is modified 6 times in CouchDB.
- The document is then deleted in CouchDB.
- The replication is triggered.
➡️ At this point, the document is NOT deleted in PouchDB.
If I increase revs_limit to 10 with same process, the deletion propagates correctly.
🧩 Investigation
The deletion status is determined via this code (extracted from PouchDB):
// check if a specific revision of a doc has been deleted
// - metadata: the metadata object from the doc store
// - rev: (optional) the revision to check. defaults to winning revision
function isDeleted(metadata, rev) {
if (!rev) {
rev = winningRev(metadata);
}
var id = rev.substring(rev.indexOf('-') + 1);
var toVisit = metadata.rev_tree.map(getTrees);
var tree;
while ((tree = toVisit.pop())) {
if (tree[0] === id) {
return !!tree[1].deleted;
}
toVisit = toVisit.concat(tree[2]);
}
}
Here’s an example of the replicated document metadata:
{
"id": "header:test7",
"deleted": true,
"revisions": {
"start": 7,
"ids": [
"6f8c91dbbaeaddfc94972b3b912a8b43",
"1e0a89380ff99cc556d5f8518afb39a7",
"520f3eb9ca9c2f925f63b363c80774ae"
]
},
"rev_tree": [
{
"pos": 1,
"ids": ["637b045152350553a2ad642d05975297", { "status": "available" }, []]
},
{
"pos": 5,
"ids": [
"520f3eb9ca9c2f925f63b363c80774ae",
{ "status": "missing" },
[
[
"1e0a89380ff99cc556d5f8518afb39a7",
{ "status": "missing" },
[
[
"6f8c91dbbaeaddfc94972b3b912a8b43",
{ "status": "available", "deleted": true },
[]
]
]
]
]
]
}
],
"seq": 8840
}
In this case:
- The rev at
pos: 1corresponds to the first revision (from the initial replication). - The rev at
pos: 5corresponds to the deleted revision. - However, the ID passed to the function is the one from
pos: 1(637b045152350553a2ad642d05975297), which doesn't match the deleted branch in therev_tree.
Thus, the document never gets deleted in PouchDB.
❓ Question
Is this expected behavior when using a low revs_limit?
Is there a way to ensure that document deletions replicate correctly even when the deleted revision is from a "longer" branch that replaces a truncated one?
- 主要言語
- JavaScript
- スター
- 17.6k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/pouchdb のほかの issue
-
elemMatch throws TypeError: value is null if array has null element対応中かも @henyanagar が 146 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
似ている issue
-
xsd:integer cast from a string rejects negative numbers, a leading + and surrounding whitespaceオープンbug 🐛
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
comunica/comunica#1960 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-javascript#26203 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bytedance/flowgram.ai#1235 ·
メンテナーはふだん 1 日以内に返信