summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/couchdb/couch_db.erl3
-rw-r--r--src/couchdb/couch_httpd.erl2
-rw-r--r--src/couchdb/couch_rep.erl51
3 files changed, 31 insertions, 25 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 96c78155..2dc863dc 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -833,8 +833,7 @@ update_docs_int(Db, DocsList, Options) ->
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 ->
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 95693262..52aa1507 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -696,7 +696,7 @@ finish_view_fold(Req, FoldResult) ->
% send empty view
send_json(Req, 200, {obj, [
{total_rows, TotalRows},
- {rows, []}
+ {rows, {}}
]});
{ok, _TotalRows, {_, _, Resp, AccRevRows}} ->
% end the view
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index f6fd0fad..0d914af0 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -48,37 +48,44 @@ replicate(Source, Target, Options) ->
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 @@ get_missing_revs_loop(Parent, DbTarget, OpenDocsPid, RevsChecked, MissingFound)
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 @@ open_doc_revs_loop(Parent, DbSource, SaveDocsPid, DocsRead) ->
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 @@ save_docs_loop(Parent, DbTarget, DocsWritten) ->
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.