You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Antoine Kurukchi <an...@gmail.com> on 2010/10/26 16:50:09 UTC
Bidirectional replication and new documents
Hi All,
Been reading a lot about couchdb and am really impressed by it. Great
work. I have got a few questions about replication and new documents.
A lot is mentioned about continuous replication and bidirectional
replication but is it possible to have both features working at the
same time? If it is possible, what happens if there is a disconnection
between the two database servers and are there any pit falls with this
approach?
I have been assuming that if you get the split brain scenario
occurring when you have multiple database server and new documents
(different ones) are inserted into both halves, the system wouldn't
get into a conflict. Is this correct?
As an example, if I have 2 servers and the link between them becomes
non functional. Users add documents to both servers. When the servers
reconnect and do a bidirectional replication, are all the new
documents added to both servers?
Thanks,
Antoine
Re: Bidirectional replication and new documents
Posted by Antoine Kurukchi <an...@gmail.com>.
Thanks for the warm welcome. It's really great that all this
functionality is in the database from the get go. I've got couchdb
running on a couple of machines now and testing how it performs.
I should explain what I'm trying to do. I'm looking at having 1-2
master couchdb servers(use continuous replication here) and then have
multiple(100 or so) client couchdb connecting up and doing a pull
replication. The client database would serve a local application (even
if the client isn't on the net). I was thinking I can do a push
replication from the clients to the server to update. From what has
been said it looks like it would work. Think I will need to be careful
with the id fields.
http://johnpwood.net/2009/06/30/couchdb-databases-and-documents/
suggests that couchdb generated keys won't work well and I think it
won't in my case.
As an alternative I can keep the client databases as read only and
would store the updates in a separate xml file or something. Update
when I know internet is available. It will ensure that no conflicts
can happen between the clients and servers.
Back to figuring out why replication fails when using nginx and
couchdb as a subdirectory.
Thanks again
Antoine
On Tue, Oct 26, 2010 at 8:31 PM, Randall Leeds <ra...@gmail.com> wrote:
> On Tue, Oct 26, 2010 at 11:52, Dave Cottlehuber <da...@muse.net.nz> wrote:
>> On 27 October 2010 03:50, Antoine Kurukchi <an...@gmail.com> wrote:
>>> Hi All,
>>>
>>> Been reading a lot about couchdb and am really impressed by it. Great
>>> work. I have got a few questions about replication and new documents.
>>
>> Welcome aboard the couch, Antoine.
>>
>>> A lot is mentioned about continuous replication and bidirectional
>>> replication but is it possible to have both features working at the
>>> same time? If it is possible, what happens if there is a disconnection
>>> between the two database servers and are there any pit falls with this
>>> approach?
>
> Bi-directional replication isn't really a "thing" in CouchDB. There's
> been mention recently of adding API sugar to make it easy, but it's
> just two replications. Whether they are continuous or not is
> irrelevant.
>
>>
>> I've had continuous replication running for some time on a small 3-way
>> replicated couch without any issues, in a multi-master mesh (mmm). I
>> believe there may be a timeout - can anybody confirm?
>
> For pull replication, there is no timeout on the source. The source
> will stream changes to the target with empty lines every ten seconds
> as a heartbeat. If the target misses 3 of these it will give up. So
> you have 30 seconds of disconnection before a continuous pull will
> fail. The command to start continuous replication is idempotent,
> though, so it's easy to set up a job that ensures it's always running
> by triggering it every minute or so. In the next release there should
> be a way to tell CouchDB about persistent replication jobs that should
> always be running.
>
> For push replication there is no longpoll on the database changes.
> Instead, you'll only see a failure if one of the individual requests
> totally fails (10 times, with exponential backoff, I think it comes
> out to around 10-15 minutes of disconnection before it'll die).
>
> Looks like Dave answered the rest of your questions. Welcome aboard.
>
Re: Bidirectional replication and new documents
Posted by Randall Leeds <ra...@gmail.com>.
On Tue, Oct 26, 2010 at 11:52, Dave Cottlehuber <da...@muse.net.nz> wrote:
> On 27 October 2010 03:50, Antoine Kurukchi <an...@gmail.com> wrote:
>> Hi All,
>>
>> Been reading a lot about couchdb and am really impressed by it. Great
>> work. I have got a few questions about replication and new documents.
>
> Welcome aboard the couch, Antoine.
>
>> A lot is mentioned about continuous replication and bidirectional
>> replication but is it possible to have both features working at the
>> same time? If it is possible, what happens if there is a disconnection
>> between the two database servers and are there any pit falls with this
>> approach?
Bi-directional replication isn't really a "thing" in CouchDB. There's
been mention recently of adding API sugar to make it easy, but it's
just two replications. Whether they are continuous or not is
irrelevant.
>
> I've had continuous replication running for some time on a small 3-way
> replicated couch without any issues, in a multi-master mesh (mmm). I
> believe there may be a timeout - can anybody confirm?
For pull replication, there is no timeout on the source. The source
will stream changes to the target with empty lines every ten seconds
as a heartbeat. If the target misses 3 of these it will give up. So
you have 30 seconds of disconnection before a continuous pull will
fail. The command to start continuous replication is idempotent,
though, so it's easy to set up a job that ensures it's always running
by triggering it every minute or so. In the next release there should
be a way to tell CouchDB about persistent replication jobs that should
always be running.
For push replication there is no longpoll on the database changes.
Instead, you'll only see a failure if one of the individual requests
totally fails (10 times, with exponential backoff, I think it comes
out to around 10-15 minutes of disconnection before it'll die).
Looks like Dave answered the rest of your questions. Welcome aboard.
Re: Bidirectional replication and new documents
Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 27 October 2010 03:50, Antoine Kurukchi <an...@gmail.com> wrote:
> Hi All,
>
> Been reading a lot about couchdb and am really impressed by it. Great
> work. I have got a few questions about replication and new documents.
Welcome aboard the couch, Antoine.
> A lot is mentioned about continuous replication and bidirectional
> replication but is it possible to have both features working at the
> same time? If it is possible, what happens if there is a disconnection
> between the two database servers and are there any pit falls with this
> approach?
I've had continuous replication running for some time on a small 3-way
replicated couch without any issues, in a multi-master mesh (mmm). I
believe there may be a timeout - can anybody confirm?
If you've got continuous replication, when connectivity is re-established,
your repl kicks in again where it left off.
> I have been assuming that if you get the split brain scenario
> occurring when you have multiple database server and new documents
> (different ones) are inserted into both halves, the system wouldn't
> get into a conflict. Is this correct?
Docs are idempotent, so no, no conflict. It's only updates to existing docs
that matter. If the update is identical then there's also no conflict.
> As an example, if I have 2 servers and the link between them becomes
> non functional. Users add documents to both servers. When the servers
> reconnect and do a bidirectional replication, are all the new
> documents added to both servers?
Yes. There's a nice work-through of replication @ Chris Strom's blog at
http://japhr.blogspot.com/2010/02/couchdb-automated-replication-confusion.html
http://japhr.blogspot.com/2010/03/circular-replication-with-couchdb.html
> Thanks,
>
> Antoine
>
A+
Dave