leofs icon indicating copy to clipboard operation
leofs copied to clipboard

[all] prevent gen_servers from getting stuck with lots of messages

Open mocchira opened this issue 7 years ago • 1 comments

Details are described here https://github.com/leo-project/leofs/issues/725#issuecomment-305393080. In order to make such stuck happen as less times as possible, we can make a request to a gen_server more scalable/responsive in specific cases by

  • Get the actual work started when there is NO requests to that work
  • Wait for the work to be completed when there are already requests to that work

The reference implementation can be found here

  • https://github.com/erlang/otp/blob/master/lib/os_mon/src/memsup.erl

The process calling get_memory_usage/1 is spawned ONLY when there is no spawned process and all callers wait for finishing the spawned process and a response sent back to them through reply/3 with pending PIDs.

https://github.com/leo-project/leo_tran might be generic solution to this sort of problems.

mocchira avatar Jun 02 '17 07:06 mocchira

Also https://github.com/ferd/pobox should be considered in general cases for safe.

mocchira avatar Apr 04 '18 06:04 mocchira