Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 80117 invoked from network); 13 Feb 2011 05:43:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Feb 2011 05:43:08 -0000 Received: (qmail 25693 invoked by uid 500); 13 Feb 2011 05:43:06 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 25498 invoked by uid 500); 13 Feb 2011 05:43:02 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 25490 invoked by uid 99); 13 Feb 2011 05:43:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Feb 2011 05:43:01 +0000 X-ASF-Spam-Status: No, hits=2.9 required=5.0 tests=FREEMAIL_FROM,FS_REPLICA,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of randall.leeds@gmail.com designates 209.85.161.52 as permitted sender) Received: from [209.85.161.52] (HELO mail-fx0-f52.google.com) (209.85.161.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Feb 2011 05:42:54 +0000 Received: by fxm5 with SMTP id 5so4030559fxm.11 for ; Sat, 12 Feb 2011 21:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=ZmTULttjnd4UfFPkX6Wa4OrJ5FqB/mdJy10dxW2TmcE=; b=Np3H6bNmeCBeGsESw2Ep/09bOv8pODEKBbmMM1tz357Rli3ASV8lPxe/b5SuIpYw4R NORQA2kIqKaa1i9hPzGNp9cIpYGWyeWCPsPUuE4cFjQOOuArJqIYabRzUdjE6YugqJQr l8FsV/RcO5C1pT47ziJ/RatSxmgKS8tr+qEIg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=ZjpjIS8mwQZVZ/O0S8XElmsKmCmYZ5DT0pmj8pRLY2XDMt9r2bpuNXQ1RBGYNH2q5a E2myPxQdxREJEXyWRer4SEx0ua1F6moMYG93bRxakbmZNJknnlhQGRd4yyQjILkW0gpY v50fp2ikFimD0QlqSnK7DcVvE1qaBeKVwmdHs= MIME-Version: 1.0 Received: by 10.223.87.1 with SMTP id u1mr2700733fal.112.1297575753024; Sat, 12 Feb 2011 21:42:33 -0800 (PST) Received: by 10.223.87.77 with HTTP; Sat, 12 Feb 2011 21:42:32 -0800 (PST) In-Reply-To: References: Date: Sat, 12 Feb 2011 21:42:32 -0800 Message-ID: Subject: Re: CouchDB Replication From: Randall Leeds To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Feb 12, 2011 at 11:11, Jim Zombek wrote: > > What is the best way to determine what documents were replicated from sou= rce to > target after a sucessfull replication? > (Let's try this as plain text) Good question! You can do something like this: @target host GET /target =3D> {... "update_seq": X, ...} POST /_replicate {"source": "/source", "target": "target"} =3D= > {...} GET /target/_changes?since=3DX =3D> { //here are your replicated changes } This last request to /target/_changes will also include any writes to the target database that occurred between the initial GET and /_replicate as well as any writes that occurred after the replication but before the /target/_changes request. If you can only make direct requests against the target database then it is impossible to guarantee an exact answer in the presence of concurrent updates to the target. On the other hand, if you are performing a push replication from a local database or can otherwise afford to request changes from the source after the replication finishes, you can get exactly what you want even in the presence of concurrent updates to the source and/or the target using the response body from the replication request. For push replication: @source host POST /_replicate {"source": "source", "target": "/target"} =3D= > =C2=A0 {..., "start_last_seq": A, "end_last_seq": B, ....} GET /source/_changes?since=3DA& limit=3DX =3D> { //this is what you want } where X =3D B - A. For pull replication: @target host POST /_replicate {"source": "/source", "target": "target"} =3D= > =C2=A0 {..., "start_last_seq": A, "end_last_seq": B, ....} @source host GET /source/_changes?since=3DA&limit=3DX =3D> { //this is what you want } where X =3D B - A as above. Both databases residing on the same host makes the push and pull cases essentially identical (specifying source and target as both bare database names [pull] or as both http endpoints [a sort of pull-push with CouchDB acting as a middleman replication proxy]) Hope that helps. Randall