couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1177549 - /couchdb/branches/1.2.x/src/couchdb/couch_replicator.erl
Date Fri, 30 Sep 2011 08:09:39 GMT
Author: fdmanana
Date: Fri Sep 30 08:09:38 2011
New Revision: 1177549

URL: http://svn.apache.org/viewvc?rev=1177549&view=rev
Log:
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.

This is a backport of revision 1177548 from trunk.

Modified:
    couchdb/branches/1.2.x/src/couchdb/couch_replicator.erl

Modified: couchdb/branches/1.2.x/src/couchdb/couch_replicator.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.2.x/src/couchdb/couch_replicator.erl?rev=1177549&r1=1177548&r2=1177549&view=diff
==============================================================================
--- couchdb/branches/1.2.x/src/couchdb/couch_replicator.erl (original)
+++ couchdb/branches/1.2.x/src/couchdb/couch_replicator.erl Fri Sep 30 08:09:38 2011
@@ -597,8 +597,18 @@ spawn_changes_reader(StartSeq, Db, Chang
 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)



Mime
View raw message