Anurag Vohra
Anurag Vohra

Reputation: 1993

Deleted documents of local clients are not reflecting in remote server after replication

I have written my own JavaScript based CouchDB replication client.

I have a doc at my local client which, I have deleted. {"_id":"5ebe99c6b179d0be4ff05bd43d0038d1","_deleted":true,"_rev":"2-c6667ac72ec89a03496f6e402265a2eba6a1d695"}

I make a bulk doc request to push it to couchdb server. I get empty array as response. I check on remote couchdb server using /{db}/doc_id?rev=deleted_doc_rev, and its present there too.

However I still see the doc at remote server, in spite of the fact that the doc is deleted and is replicated too.

Upvotes: 0

Views: 49

Answers (1)

Anurag Vohra
Anurag Vohra

Reputation: 1993

Ok Guys,

The problem was in my replicator.I created my replicator without considering MVCC structure of CouchDB. In the replication protocol while making bulk request one need to send the MVCC structure present locally to server, to override the current branch at the server(couchdb).

Previously my bulk reqeust would be like:

POST http://0.0.0.0:5984/{db}/_bulk_docs

{
  "docs" : [ {
    "_id" : "5ebe99c6b179d0be4ff05bd43d0038d1",
    "_deleted" : true,
    "_rev" : "2-c6667ac72ec89a03496f6e402265a2eba6a1d695"
  } ],
  "new_edits" : false
}

However for getting the correct MVCC based replication, one need to make bulk request like this:

POST http://0.0.0.0:5984/{db}/_bulk_docs

{
  "docs" : [ {
    "_deleted" : true,
    "_id" : "5ebe99c6b179d0be4ff05bd43d0038d1",
    "_rev" : "2-7a5de99d17a4504b2f74cda829bf7054",
    "_revisions" : {
      "start" : 2,
      "ids" : [ "7a5de99d17a4504b2f74cda829bf7054", "0c4f4e08acc7931c290193b1434f5e2b" ]
    }
  } ],
  "new_edits" : false
}

I figured this by studying traffic between correct replicator implementations.

Upvotes: 0

Related Questions