Search code examples
couchdbreplication

CouchDB with continuous replication reverts document revision instead of deleting


We have a system that uses CouchDB as its database. We are using continuous replication to create an always-updated copy of our database.

Recently we have discovered a strange behavior (maybe bug?) that I hope someone here could help me with:

We set the system with normal replication (NOT filtered).

We update the same document several times consecutively (each time waiting for CouchDB to return 200ok) - this part works fine and the document appears to be updated just fine in the replicated DB.

However, when we try to delete this document, even minutes after the consecutive updates, it is not deleted in the replication DB and instead just reverts to a revision before the consecutive updates.

It is important to note that we delete by adding a _deleted field set to true

I understand there is some problem with deletion using HTTP DELETE combined with filtered replication, but we're not using either. Also, doing the same updates and just waiting a second between one and the other solves the problem just fine (or just combining them to one update). However both solutions are not possible and at any case just go around the problem.

tl;dr:

1) CouchDB with normal continuous replication

2) Consecutive updates to document

3) _deleted = trueto document

4) Replicated DB does not delete, instead reverts to _rev before #2

Environment:

CouchDB version is 1.6.1

Windows computer

Using CouchDB-Lucene


Solution

  • Problem solved. It was the revision limit. Seems that quickly doing changes that are over the revision limit causes problem for the replication mechanism.

    There is an unsolved bug in CouchDB about this issue: https://issues.apache.org/jira/browse/COUCHDB-1649

    Since the revision limit we had was 2, doing 3 consecutive updates to the same document and then deleting it caused this problem. Setting the revision limit to 5 avoids it.