You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2011/10/26 20:05:33 UTC

[28/50] git commit: Replicator: skip documents with empty ID

Replicator: skip documents with empty ID

Due to a bug, older releases allowed the creation of
documents with an empty ID, which are impossible to
GET therefore making the replicator crash.
This change simply skips such documents and logs
an error message to inform users.




git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1177548 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/daf264b5
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/daf264b5
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/daf264b5

Branch: refs/heads/1319-large-headers-are-corrupted
Commit: daf264b52099717ae481143c0824683e7474e423
Parents: 218c84e
Author: Filipe David Borba Manana <fd...@apache.org>
Authored: Fri Sep 30 08:08:49 2011 +0000
Committer: Filipe David Borba Manana <fd...@apache.org>
Committed: Fri Sep 30 08:08:49 2011 +0000

----------------------------------------------------------------------
 src/couchdb/couch_replicator.erl |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/daf264b5/src/couchdb/couch_replicator.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_replicator.erl b/src/couchdb/couch_replicator.erl
index 315cec4..663ce27 100644
--- a/src/couchdb/couch_replicator.erl
+++ b/src/couchdb/couch_replicator.erl
@@ -597,8 +597,18 @@ spawn_changes_reader(StartSeq, Db, ChangesQueue, Options) ->
 read_changes(StartSeq, Db, ChangesQueue, Options) ->
     try
         couch_api_wrap:changes_since(Db, all_docs, StartSeq,
-            fun(#doc_info{high_seq = Seq} = DocInfo) ->
-                ok = couch_work_queue:queue(ChangesQueue, DocInfo),
+            fun(#doc_info{high_seq = Seq, id = Id} = DocInfo) ->
+                case Id of
+                <<>> ->
+                    % Previous CouchDB releases had a bug which allowed a doc
+                    % with an empty ID to be inserted into databases. Such doc
+                    % is impossible to GET.
+                    ?LOG_ERROR("Replicator: ignoring document with empty ID in "
+                        "source database `~s` (_changes sequence ~p)",
+                        [couch_api_wrap:db_uri(Db), Seq]);
+                _ ->
+                    ok = couch_work_queue:queue(ChangesQueue, DocInfo)
+                end,
                 put(last_seq, Seq)
             end, Options),
         couch_work_queue:close(ChangesQueue)