nickva commented on code in PR #5986:
URL: https://github.com/apache/couchdb/pull/5986#discussion_r3193003095


##########
src/couch_index/src/couch_index_server.erl:
##########
@@ -358,51 +361,9 @@ handle_db_event(DbName, created, St) ->
 handle_db_event(DbName, deleted, St) ->
     gen_server:cast(St#st.server_name, {reset_indexes, DbName}),
     {ok, St};
-handle_db_event(<<"shards/", _/binary>> = DbName, {ddoc_updated, DDocId}, St) 
->
-    %% this handle_db_event function must not crash (or it takes down the 
couch_index_server)
-    try
-        DDocResult = couch_util:with_db(DbName, fun(Db) ->
-            couch_db:open_doc(Db, DDocId, [ejson_body, ?ADMIN_CTX])
-        end),
-        LocalShards = mem3:local_shards(mem3:dbname(DbName)),
-        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
-                        SigDDocs = ets:match_object(St#st.by_db, {DbShard, 
{'$1', Sig}}),
-                        if
-                            length(SigDDocs) > 1 ->
-                                % remove records from by_db for this DDoc
-                                Args = [DbShard, DDocId, Sig],
-                                gen_server:cast(St#st.server_name, 
{rem_from_ets, Args});
-                            true ->
-                                % single DDoc with this Sig - close 
couch_index processes
-                                case ets:lookup(St#st.by_sig, {DbShard, Sig}) 
of
-                                    [{_, IndexPid}] ->
-                                        (catch gen_server:cast(
-                                            IndexPid, {ddoc_updated, 
DDocResult}
-                                        ));
-                                    [] ->
-                                        []
-                                end
-                        end
-                    end,
-                    ets:match_object(St#st.by_db, {DbShard, {DDocId, '$1'}})
-                )
-            end,
-            DbShards
-        ),
-        {ok, St}
-    catch
-        Class:Reason:Stack ->
-            couch_log:warning("~p: handle_db_event ~p for db ~p, reason ~p, 
stack ~p", [
-                ?MODULE, Class, DbName, Reason, Stack
-            ]),
-            gen_server:cast(St#st.server_name, {rem_from_ets, [DbName, 
Reason]}),

Review Comment:
   Good question! That's to skip over the clustered db shard names (they start 
with `<<"shards/...">>`) since we're handling them somewhere else now, but we 
still want handle the node-local dbs (the next clause) like we did before. If 
remove the `<<"shards/...">>` we'll end up handling both the clustered and 
local dbs in the same way which would be a new behavior from before



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to