You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2020/08/14 15:48:54 UTC

[couchdb] branch couch_index_server_crash2-3.x created (now 06ab38d)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch couch_index_server_crash2-3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 06ab38d  Don't crash couch_index_server if the db isn't known yet

This branch includes the following new commits:

     new 06ab38d  Don't crash couch_index_server if the db isn't known yet

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Don't crash couch_index_server if the db isn't known yet

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch couch_index_server_crash2-3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 06ab38d0c7607abeea7d63aeb47a5229fe0129da
Author: Robert Newson <ro...@uk.ibm.com>
AuthorDate: Thu Aug 13 14:23:24 2020 +0100

    Don't crash couch_index_server if the db isn't known yet
    
    If a ddoc is added immediately after database creation (_users and
    _replicator when couchdb is used in a multi-tenant fashion), we can
    crash couch_index_server in handle_db_event, as mem3_shards:local
    throws an error.
---
 src/couch_index/src/couch_index_server.erl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/couch_index/src/couch_index_server.erl b/src/couch_index/src/couch_index_server.erl
index 67f0f8c..6bebff2 100644
--- a/src/couch_index/src/couch_index_server.erl
+++ b/src/couch_index/src/couch_index_server.erl
@@ -284,7 +284,11 @@ handle_db_event(<<"shards/", _/binary>> = DbName, {ddoc_updated,
     DDocResult = couch_util:with_db(DbName, fun(Db) ->
         couch_db:open_doc(Db, DDocId, [ejson_body, ?ADMIN_CTX])
     end),
-    DbShards = [mem3:name(Sh) || Sh <- mem3:local_shards(mem3:dbname(DbName))],
+    LocalShards = try mem3:local_shards(mem3:dbname(DbName))
+        catch error:database_does_not_exist ->
+            []
+    end,
+    DbShards = [mem3:name(Sh) || Sh <- LocalShards],
     lists:foreach(fun(DbShard) ->
         lists:foreach(fun({_DbShard, {_DDocId, Sig}}) ->
             % check if there are other ddocs with the same Sig for the same db