Document Deletion Not Replicated with Low revs_limit (CouchDB → PouchDB)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, react-native
- Área
- databases, mobile-dev
Línea de trabajo
Comienza con la función isDeleted y los metadatos rev_tree proporcionados; después, reproduce el escenario de CouchDB-to-PouchDB con un revs_limit bajo y varias actualizaciones antes de la eliminación. Se considera terminado cuando se confirme la causa y se garantice que el documento eliminado se quite de PouchDB cuando la eliminación ocurre después de un historial de revisiones truncado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🔄 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?
- Lenguaje dominante
- JavaScript
- Estrellas
- 17.6k
- Forks
- 1.5k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/pouchdb
-
elemMatch throws TypeError: value is null if array has null elementPosiblemente ocupada @henyanagar la tomó hace 146 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
unref event is not documentedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Validate database namesAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
Todos los issues de apache/pouchdb
Issues similares
-
Waiting for: Product Owner
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
getsentry/sentry-javascript#26203 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
bytedance/flowgram.ai#1235 ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
open-webui/docs#1500 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días