couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject git commit: Fix replicator db changes loop crash after _security update
Date Fri, 02 Dec 2011 12:50:11 GMT
Updated Branches:
  refs/heads/master 4d9f690da -> 0c6f529a7


Fix replicator db changes loop crash after _security update

The changes feed loop on the replicator database would crash
if this database's _security object was updated.

Closes COUCHDB-1353.


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

Branch: refs/heads/master
Commit: 0c6f529a73c8ce4e81e95e90eabf2f0b772b3a64
Parents: 4d9f690
Author: Filipe David Borba Manana <fdmanana@apache.org>
Authored: Fri Dec 2 12:47:26 2011 +0000
Committer: Filipe David Borba Manana <fdmanana@apache.org>
Committed: Fri Dec 2 12:47:26 2011 +0000

----------------------------------------------------------------------
 share/www/script/test/replicator_db.js    |   40 ++++++++++++++++++++++++
 src/couchdb/couch_replication_manager.erl |    3 +-
 2 files changed, 42 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0c6f529a/share/www/script/test/replicator_db.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/replicator_db.js b/share/www/script/test/replicator_db.js
index 058b6a7..46d3873 100644
--- a/share/www/script/test/replicator_db.js
+++ b/share/www/script/test/replicator_db.js
@@ -1341,6 +1341,42 @@ couchTests.replicator_db = function(debug) {
   }
 
 
+  function test_rep_db_update_security() {
+    var dbA_copy = new CouchDB("test_suite_rep_db_a_copy");
+    var dbB_copy = new CouchDB("test_suite_rep_db_b_copy");
+    var repDoc1, repDoc2;
+    var xhr, i, doc, copy, new_doc;
+    var docs = makeDocs(1, 3);
+
+    populate_db(dbA, docs);
+    populate_db(dbB, docs);
+    populate_db(dbA_copy, []);
+    populate_db(dbB_copy, []);
+
+    repDoc1 = {
+      _id: "rep1",
+      source: CouchDB.protocol + host + "/" + dbA.name,
+      target: dbA_copy.name
+    };
+    repDoc2 = {
+      _id: "rep2",
+      source: CouchDB.protocol + host + "/" + dbB.name,
+      target: dbB_copy.name
+    };
+
+    TEquals(true, repDb.save(repDoc1).ok);
+    waitForRep(repDb, repDoc1, "completed");
+
+    T(repDb.setSecObj({
+      readers: {
+        names: ["joe"]
+      }
+    }).ok);
+
+    TEquals(true, repDb.save(repDoc2).ok);
+    waitForRep(repDb, repDoc2, "completed");
+  }
+
   // run all the tests
   var server_config = [
     {
@@ -1422,6 +1458,10 @@ couchTests.replicator_db = function(debug) {
   restartServer();
   run_on_modified_server(server_config, test_invalid_filter);
 
+  repDb.deleteDb();
+  restartServer();
+  run_on_modified_server(server_config, test_rep_db_update_security);
+
 /*
  * Disabled, since error state would be set on the document only after
  * the exponential backoff retry done by the replicator database listener

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0c6f529a/src/couchdb/couch_replication_manager.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_replication_manager.erl b/src/couchdb/couch_replication_manager.erl
index 1c038d6..801af7c 100644
--- a/src/couchdb/couch_replication_manager.erl
+++ b/src/couchdb/couch_replication_manager.erl
@@ -228,7 +228,8 @@ changes_feed_loop() ->
     Server = self(),
     Pid = spawn_link(
         fun() ->
-            {ok, Db} = couch_db:open_int(RepDbName, [sys_db]),
+            DbOpenOptions = [{user_ctx, RepDb#db.user_ctx}, sys_db],
+            {ok, Db} = couch_db:open_int(RepDbName, DbOpenOptions),
             ChangesFeedFun = couch_changes:handle_changes(
                 #changes_args{
                     include_docs = true,


Mime
View raw message