incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <>
Subject Re: Questions on replication (how to prevent DELETEs and resync deleted documents)
Date Sun, 27 Dec 2009 17:34:18 GMT
On Sun, Dec 27, 2009 at 9:17 AM, Troy Kruthoff <> wrote:
> I believe the revision does change when you delete the doc, meaning the
> delete will be replicated to your "master" for which you can monitor changes
> and un-delete the document, causing it's rev to again be modified and
> re-replicated to the slaves.
> Troy

That is a fine solution. One side effect is that every edge node will
see all the undeletes as triggered by deletes on every edge node, so
for normal users (those not doing sneaky deletes) you'll be pushing a
lot of unnecessary changes around.

However, if you want to prevent deletes on the master altogether, you
can use a validation function to do this. In this case, replication to
the "master" will ignore all deletes.

This doesn't handle the undeleting case... The best solution here
would be to replicate the validation function to the edge dbs, so that
deletes there are also not allowed. To make a delete at the edge you'd
have to first delete the design document with it's validation
function, and then delete the docs. If someone is willing to go to
those lengths, I'd consider myself free of any obligation to un-delete
the docs at their node.

If you really want to undelete the docs at the edge nodes, you'd have
to edit them at the master node, but then the edges would end up with
conflicts upon re-replicating.

For info on validation functions:


> On Dec 27, 2009, at 8:38 AM, fana wrote:
>> Hi,
>> yesterday I played around with CouchDB's (0.10) replication feature.
>> I have a database which should be something like a "master".
>> Means, I want to replicate its complete content to other databases
>> and from them all content back to the master.
>> But I want to prevent documents to be deleted on the master
>> which have (accidentally or not) been deleted on one of the other
>> databases.
>> I also want the master to resync the documents which were deleted on the
>> other databases.
>> After playing around and reading the documentation
>> I found that deleted documents get only resynced again
>> if the revision was changed so the document appears in the "_changes"
>> resource.
>> Is it somehow possible to build a scenario like this?
>> So,
>> * How can I resync deleted documents
>> without touching the doument and getting a new revision?
>> * How can I prevent documents to be deleted
>> and only integrate new or changed documents to the master?
>> Thanks in advance

Chris Anderson

View raw message