rnewson commented on a change in pull request #3366:
URL: https://github.com/apache/couchdb/pull/3366#discussion_r574052515



##########
File path: src/couch/src/couch_server.erl
##########
@@ -860,19 +865,55 @@ get_engine_path(DbName, Engine) when is_binary(DbName), 
is_atom(Engine) ->
     end.
 
 lock(DbName, Reason) when is_binary(DbName), is_binary(Reason) ->
-    case ets:lookup(couch_dbs, DbName) of
+    case ets:lookup(couch_dbs(DbName), DbName) of
         [] ->
-            true = ets:insert(couch_dbs_locks, {DbName, Reason}),
+            true = ets:insert(couch_dbs_locks(DbName), {DbName, Reason}),
             ok;
         [#entry{}] ->
             {error, already_opened}
     end.
 
 unlock(DbName) when is_binary(DbName) ->
-    true = ets:delete(couch_dbs_locks, DbName),
+    true = ets:delete(couch_dbs_locks(DbName), DbName),
     ok.
 
 
+db_updated(Db) ->
+    DbName = couch_db:name(Db),
+    gen_server:call(couch_server(DbName), {db_updated, Db}, infinity).
+
+
+couch_server(Arg) ->
+    name("couch_server", Arg).
+
+
+couch_dbs(Arg) ->
+    name("couch_dbs", Arg).
+
+
+couch_dbs_pid_to_name(Arg) ->
+    name("couch_dbs_pid_to_name", Arg).
+
+
+couch_dbs_locks(Arg) ->
+    name("couch_dbs_locks", Arg).
+
+
+name(BaseName, DbName) when is_binary(DbName) ->
+    N = 1 + (erlang:crc32(DbName) rem num_servers()),
+    name(BaseName, N);
+
+name(BaseName, #server{} = Srv) ->
+    name(BaseName, Srv#server.n);

Review comment:
       I thought about it but there are a fair few paths where we're not inside 
the couch_server gen process, but I'll look to see if we can do it tidily.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to