couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
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 GMT
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.
 
 



Mime
View raw message