Return-Path: Delivered-To: apmail-incubator-couchdb-commits-archive@locus.apache.org Received: (qmail 4662 invoked from network); 23 Apr 2008 02:23:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Apr 2008 02:23:30 -0000 Received: (qmail 92074 invoked by uid 500); 23 Apr 2008 02:23:31 -0000 Delivered-To: apmail-incubator-couchdb-commits-archive@incubator.apache.org Received: (qmail 92034 invoked by uid 500); 23 Apr 2008 02:23:31 -0000 Mailing-List: contact couchdb-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-commits@incubator.apache.org Received: (qmail 92023 invoked by uid 99); 23 Apr 2008 02:23:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2008 19:23:31 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Apr 2008 02:22:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4E87D1A9832; Tue, 22 Apr 2008 19:23:09 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r650729 - in /incubator/couchdb/trunk/src/couchdb: couch_db.erl couch_httpd.erl couch_rep.erl Date: Wed, 23 Apr 2008 02:23:08 -0000 To: couchdb-commits@incubator.apache.org From: damien@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080423022309.4E87D1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: damien Date: Tue Apr 22 19:23:02 2008 New Revision: 650729 URL: http://svn.apache.org/viewvc?rev=650729&view=rev Log: Fix for replication being reset when replication a local and a remote database. Modified: incubator/couchdb/trunk/src/couchdb/couch_db.erl incubator/couchdb/trunk/src/couchdb/couch_httpd.erl incubator/couchdb/trunk/src/couchdb/couch_rep.erl Modified: incubator/couchdb/trunk/src/couchdb/couch_db.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_db.erl?rev=650729&r1=650728&r2=650729&view=diff ============================================================================== --- incubator/couchdb/trunk/src/couchdb/couch_db.erl (original) +++ incubator/couchdb/trunk/src/couchdb/couch_db.erl Tue Apr 22 19:23:02 2008 @@ -833,8 +833,7 @@ docinfo_by_seq_btree = DocInfoBySeqBTree2, update_seq = NewSeq, doc_count = FullDocCount + NewDocsCount - OldCount, - doc_del_count = FullDelCount + NewDelCount - OldDelCount - }, + doc_del_count = FullDelCount + NewDelCount - OldDelCount}, case lists:member(delay_commit, Options) of true -> Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=650729&r1=650728&r2=650729&view=diff ============================================================================== --- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original) +++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Tue Apr 22 19:23:02 2008 @@ -696,7 +696,7 @@ % send empty view send_json(Req, 200, {obj, [ {total_rows, TotalRows}, - {rows, []} + {rows, {}} ]}); {ok, _TotalRows, {_, _, Resp, AccRevRows}} -> % end the view Modified: incubator/couchdb/trunk/src/couchdb/couch_rep.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_rep.erl?rev=650729&r1=650728&r2=650729&view=diff ============================================================================== --- incubator/couchdb/trunk/src/couchdb/couch_rep.erl (original) +++ incubator/couchdb/trunk/src/couchdb/couch_rep.erl Tue Apr 22 19:23:02 2008 @@ -48,37 +48,44 @@ RepRecKey = ?LOCAL_DOC_PREFIX ++ HostName ++ ":" ++ Source ++ ":" ++ Target, StartTime = httpd_util:rfc1123_date(), - RepRecSrc = - case open_doc(DbSrc, RepRecKey, []) of - {ok, SrcDoc} -> SrcDoc; - _ -> #doc{id=RepRecKey} - end, - - RepRecTgt = - case open_doc(DbTgt, RepRecKey, []) of - {ok, TgtDoc} -> TgtDoc; - _ -> #doc{id=RepRecKey} + + case proplists:get_value(full, Options, false) + orelse proplists:get_value("full", Options, false) of + true -> + RepRecSrc = RepRecTgt = #doc{id=RepRecKey}; + false -> + RepRecSrc = + case open_doc(DbSrc, RepRecKey, []) of + {ok, SrcDoc} -> + ?LOG_DEBUG("Found existing replication record on source", []), + SrcDoc; + _ -> #doc{id=RepRecKey} + end, + + RepRecTgt = + case open_doc(DbTgt, RepRecKey, []) of + {ok, TgtDoc} -> + ?LOG_DEBUG("Found existing replication record on target", []), + TgtDoc; + _ -> #doc{id=RepRecKey} + end end, #doc{body={obj,OldRepHistoryProps}} = RepRecSrc, #doc{body={obj,OldRepHistoryPropsTrg}} = RepRecTgt, - SeqNum0 = + SeqNum = case OldRepHistoryProps == OldRepHistoryPropsTrg of true -> % if the records are identical, then we have a valid replication history proplists:get_value("source_last_seq", OldRepHistoryProps, 0); false -> + ?LOG_INFO("Replication records differ. " + "Performing full replication instead of incremental.", []), + ?LOG_DEBUG("Record on source:~p~nRecord on target:~p~n", [OldRepHistoryProps, OldRepHistoryPropsTrg]), 0 end, - SeqNum = - case proplists:get_value(full, Options, false) - orelse proplists:get_value("full", Options, false) of - true -> 0; - false -> SeqNum0 - end, - {NewSeqNum, Stats} = pull_rep(DbTgt, DbSrc, SeqNum), case NewSeqNum == SeqNum andalso OldRepHistoryProps /= [] of @@ -154,8 +161,8 @@ RevsChecked + length(Changed), MissingFound + length(Missing)); shutdown -> - Parent ! {done, self(), [{missing_checked, RevsChecked}, - {missing_found, MissingFound}]} + Parent ! {done, self(), [{"missing_checked", RevsChecked}, + {"missing_found", MissingFound}]} end. @@ -168,7 +175,7 @@ SaveDocsPid ! Docs, open_doc_revs_loop(Parent, DbSource, SaveDocsPid, DocsRead + length(Docs)); shutdown -> - Parent ! {done, self(), [{docs_read, DocsRead}]} + Parent ! {done, self(), [{"docs_read", DocsRead}]} end. @@ -187,7 +194,7 @@ ok = save_docs(DbTarget, Docs, []), save_docs_loop(Parent, DbTarget, DocsWritten + length(Docs)); shutdown -> - Parent ! {done, self(), [{docs_written, DocsWritten}]} + Parent ! {done, self(), [{"docs_written", DocsWritten}]} end.