couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1177550 - /couchdb/branches/1.1.x/src/couchdb/couch_rep_changes_feed.erl
Date Fri, 30 Sep 2011 08:10:31 GMT
Author: fdmanana
Date: Fri Sep 30 08:10:31 2011
New Revision: 1177550

URL: http://svn.apache.org/viewvc?rev=1177550&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.1.x/src/couchdb/couch_rep_changes_feed.erl

Modified: couchdb/branches/1.1.x/src/couchdb/couch_rep_changes_feed.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_rep_changes_feed.erl?rev=1177550&r1=1177549&r2=1177550&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_rep_changes_feed.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_rep_changes_feed.erl Fri Sep 30 08:10:31 2011
@@ -491,13 +491,30 @@ purge_req_messages(ReqId) ->
         ok
     end.
 
-queue_changes_row(Row, #state{doc_ids = nil, count = Count, rows = Rows}) ->
-    {queue:in(Row, Rows), Count + 1};
+queue_changes_row(Row, #state{doc_ids = nil} = State) ->
+    maybe_queue_row(Row, State);
 queue_changes_row({RowProps} = Row,
-    #state{doc_ids = Ids, count = Count, rows = Rows}) ->
+    #state{doc_ids = Ids, count = Count, rows = Rows} = State) ->
     case lists:member(get_value(<<"id">>, RowProps), Ids) of
     true ->
-        {queue:in(Row, Rows), Count + 1};
+        maybe_queue_row(Row, State);
     false ->
         {Rows, Count}
     end.
+
+maybe_queue_row({Props} = Row, #state{count = Count, rows = Rows} = State) ->
+    case get_value(<<"id">>, Props) of
+    <<>> ->
+        [_, Db | _] = State#state.init_args,
+        ?LOG_ERROR("Replicator: ignoring document with empty ID in source "
+            "database `~s` (_changes sequence ~p)",
+            [dbname(Db), couch_util:get_value(<<"seq">>, Props)]),
+        {Rows, Count};
+    _ ->
+        {queue:in(Row, Rows), Count + 1}
+    end.
+
+dbname(#http_db{url = Url}) ->
+    couch_util:url_strip_password(Url);
+dbname(#db{name = Name}) ->
+    Name.



Mime
View raw message