Document Deletion Not Replicated with Low revs_limit (CouchDB → PouchDB)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, react-native
- Ambito
- databases, mobile-dev
Direzione di ricerca
Inizia con la funzione isDeleted e i metadati rev_tree forniti, quindi riproduci lo scenario CouchDB-to-PouchDB con un revs_limit basso e più aggiornamenti prima dell’eliminazione. Il lavoro è completato quando la causa è confermata e si garantisce che il documento eliminato venga rimosso da PouchDB quando l’eliminazione segue una cronologia delle revisioni troncata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔄 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?
- Lingua principale
- JavaScript
- Stelle
- 17.6k
- Fork
- 1.5k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/pouchdb
-
elemMatch throws TypeError: value is null if array has null elementForse già presa @henyanagar l’ha presa 144 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Validate database namesAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
Tutte le issue di apache/pouchdb
Issue simili
-
curriculum documentation quality
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
githubnext/gh-aw-workshop#5367 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
HeyPuter/everything#187 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Animal Planet BGApertachannels:add check:passed
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 4 giorni
-
beginner blocked
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
hiero-ledger/hiero-sdk-js#4670 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 61/100
I maintainer di solito rispondono entro 1 giorno