davisp commented on a change in pull request #1182: fixed race is_idle
URL: https://github.com/apache/couchdb/pull/1182#discussion_r240048882
 
 

 ##########
 File path: src/couch/src/couch_file.erl
 ##########
 @@ -702,18 +703,25 @@ monitored_by_pids() ->
 % System dbs aren't monitored by couch_stats_process_tracker
 is_idle(#file{is_sys=true}) ->
     case monitored_by_pids() of
-        [] -> true;
+        [] -> lock(self());
         _ -> false
     end;
 is_idle(#file{is_sys=false}) ->
     Tracker = whereis(couch_stats_process_tracker),
     case monitored_by_pids() of
-        [] -> true;
-        [Tracker] -> true;
+        [] -> lock(self());
+        [Tracker] -> lock(self());
         [_] -> exit(tracker_monitoring_failed);
         _ -> false
     end.
 
+lock(Fd) -> try
+                ets:new(list_to_atom(pid_to_list(Fd)), [named_table]), true
 
 Review comment:
   While register does solve some of those issues that's gonna take a 
significant amount of work to characterize the performance. I don't think it 
was ever intended for this sort of usage. I'd like to see some fairly extensive 
benchmarking before even considering accepting this and also probably some 
fairly detailed writeup of the register internals explaining how this doesn't 
become a global lock across shard lookups.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to